Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

java.lang.ArrayIndexOutOfBoundsException

1 view
Skip to first unread message

johnson

unread,
Jan 5, 2004, 9:01:07 AM1/5/04
to
Hi, Goodmorning,

I run into an ArrayIndexOutOfBoundsException.
From the stack trace we can see that it does not really have anything
to do with our code other than one line and that runs our event
dispathing on our event queue.

My questions is:
1. Is this caused by a Swing internal bug?
2. It seems odd since from the code in (class: BlockView, method:
layoutMinorAxis), that it only assigns value to arrays offsets[] and
spans[] and there is no code trying to retrive data from the arrays.
Then even if the array is an empty one, it should still be valid to
assign a value to its first element. What could cause the
java.lang.ArrayIndexOutOfBoundsException: 0 ??

I am confused. Anybody gets any idea??
Thanks.

java.lang.ArrayIndexOutOfBoundsException: 0
at javax.swing.text.html.BlockView.layoutMinorAxis(Unknown Source)
at javax.swing.text.BoxView.setSpanOnAxis(Unknown Source)
at javax.swing.text.BoxView.layout(Unknown Source)
at javax.swing.text.BoxView.setSize(Unknown Source)
at javax.swing.plaf.basic.BasicTextUI$RootView.setSize(Unknown
Source)
at javax.swing.plaf.basic.BasicTextUI.getPreferredSize(Unknown
Source)
at javax.swing.JComponent.getPreferredSize(Unknown Source)
at javax.swing.JEditorPane.getPreferredSize(Unknown Source)
at java.awt.GridBagLayout.GetLayoutInfo(Unknown Source)
at java.awt.GridBagLayout.getLayoutInfo(Unknown Source)
at java.awt.GridBagLayout.preferredLayoutSize(Unknown Source)
at java.awt.Container.preferredSize(Unknown Source)
at java.awt.Container.getPreferredSize(Unknown Source)
at javax.swing.JComponent.getPreferredSize(Unknown Source)
at java.awt.CardLayout.preferredLayoutSize(Unknown Source)
at java.awt.Container.preferredSize(Unknown Source)
at java.awt.Container.getPreferredSize(Unknown Source)
at javax.swing.JComponent.getPreferredSize(Unknown Source)
at java.awt.GridBagLayout.GetLayoutInfo(Unknown Source)
at java.awt.GridBagLayout.getLayoutInfo(Unknown Source)
at java.awt.GridBagLayout.preferredLayoutSize(Unknown Source)
at java.awt.Container.preferredSize(Unknown Source)
at java.awt.Container.getPreferredSize(Unknown Source)
at javax.swing.JComponent.getPreferredSize(Unknown Source)
at java.awt.CardLayout.preferredLayoutSize(Unknown Source)
at java.awt.Container.preferredSize(Unknown Source)
at java.awt.Container.getPreferredSize(Unknown Source)
at javax.swing.JComponent.getPreferredSize(Unknown Source)
at java.awt.GridBagLayout.GetLayoutInfo(Unknown Source)
at java.awt.GridBagLayout.getLayoutInfo(Unknown Source)
at java.awt.GridBagLayout.preferredLayoutSize(Unknown Source)
at java.awt.Container.preferredSize(Unknown Source)
at java.awt.Container.getPreferredSize(Unknown Source)
at javax.swing.JComponent.getPreferredSize(Unknown Source)
at java.awt.CardLayout.preferredLayoutSize(Unknown Source)
at java.awt.Container.preferredSize(Unknown Source)
at java.awt.Container.getPreferredSize(Unknown Source)
at javax.swing.JComponent.getPreferredSize(Unknown Source)
at java.awt.GridBagLayout.GetLayoutInfo(Unknown Source)
at java.awt.GridBagLayout.getLayoutInfo(Unknown Source)
at java.awt.GridBagLayout.preferredLayoutSize(Unknown Source)
at java.awt.Container.preferredSize(Unknown Source)
at java.awt.Container.getPreferredSize(Unknown Source)
at javax.swing.JComponent.getPreferredSize(Unknown Source)
at java.awt.CardLayout.preferredLayoutSize(Unknown Source)
at java.awt.Container.preferredSize(Unknown Source)
at java.awt.Container.getPreferredSize(Unknown Source)
at javax.swing.JComponent.getPreferredSize(Unknown Source)
at java.awt.GridBagLayout.GetLayoutInfo(Unknown Source)
at java.awt.GridBagLayout.getLayoutInfo(Unknown Source)
at java.awt.GridBagLayout.ArrangeGrid(Unknown Source)
at java.awt.GridBagLayout.arrangeGrid(Unknown Source)
at java.awt.GridBagLayout.layoutContainer(Unknown Source)
at java.awt.Container.layout(Unknown Source)
at java.awt.Container.doLayout(Unknown Source)
at java.awt.Container.validateTree(Unknown Source)
at java.awt.Container.validateTree(Unknown Source)
at java.awt.Container.validateTree(Unknown Source)
at java.awt.Container.validate(Unknown Source)
at javax.swing.RepaintManager.validateInvalidComponents(Unknown
Source)
at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(Unknown
Source)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at com.my_company.my_project.gui.comp.My_EventQueue.dispatchEvent(My_EventQueue.java:51)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown
Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown
Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)

Bryan E. Boone

unread,
Jan 5, 2004, 9:27:56 AM1/5/04
to
Can you post any source that can be used to reproduce this exception?
-Bryan
"johnson" <yanl...@yahoo.com> wrote in message
news:709e61b1.04010...@posting.google.com...

jT

unread,
Jan 5, 2004, 10:11:38 AM1/5/04
to
Hi johnson,

without knowing the details of this problem I thought I'd point out a
mistake you made by saying:

> Then even if the array is an empty one, it should still be valid to
> assign a value to its first element. What could cause the
> java.lang.ArrayIndexOutOfBoundsException: 0 ??

This is not true. Doing what you here explain will cause exactly the
exception mentioned to be thrown. If you create an empty array with the
length of 0, you can not then add any elements to it. Element in the
position 0 of an array would be the last element of an array with length of
1.

so doing this:
int[] n = new int[0];
n[0] = 1;
will always fail.

I don't know if this will solve your problem, but hope it will guide you to
the right direction.

best regards,
-jT

0 new messages