-
Bug
-
Resolution: Fixed
-
P4
-
1.2.1, 1.2.2, 1.3.0
-
merlin
-
generic, x86
-
generic, windows_nt
Name: skT88420 Date: 06/07/99
If a JTable's autoResizeMode is set to AUTO_RESIZE_NEXT_COLUMN,
resizing the last column in the table causes an array bounds exception
in JTable's accommodateDelta() method. In the sample application
defined below, click and the drag the right border of the
right-most column (column "C"). It looks like there is no
error-checking in accommodateDelta() to verify that there
actually _is_ a "next" column.
This happens in 1.2.1 and 1.2.2.
Sample application:
// Start of MyApp definition
import javax.swing.*;
class MyApp
{
public MyApp()
{
}
public void start()
{
JFrame aFrame = new JFrame();
String[][] tableData = { {"0", "1", "2"} };
String[] tableColumnNames = {"A", "B", "C"};
JTable aTable = new JTable(tableData, tableColumnNames);
aTable.setAutoResizeMode(JTable.AUTO_RESIZE_NEXT_COLUMN);
JPanel aPanel = new JPanel();
aPanel.add( new JScrollPane(aTable) );
aPanel.setBorder( BorderFactory.createEmptyBorder(10, 10, 10, 10) );
aFrame.setContentPane(aPanel);
aFrame.pack();
aFrame.setVisible(true);
}
public static void main( String[] args )
{
MyApp app = new MyApp();
app.start();
}
}
// End of MyApp definition
Exception thrown:
Exception occurred during event dispatching:
java.lang.ArrayIndexOutOfBoundsException: 3 >= 3
at java.util.Vector.elementAt(Vector.java:410)
at javax.swing.table.DefaultTableColumnModel.getColumn(DefaultTableColum
nModel.java:261)
at javax.swing.JTable.accommodateDelta(JTable.java:1832)
at javax.swing.JTable.sizeColumnsToFit(JTable.java:1765)
at javax.swing.plaf.basic.BasicTableHeaderUI$MouseInputHandler.mouseDrag
ged(BasicTableHeaderUI.java:126)
at java.awt.AWTEventMulticaster.mouseDragged(AWTEventMulticaster.java:26
0)
at java.awt.Component.processMouseMotionEvent(Component.java:3170)
at javax.swing.JComponent.processMouseMotionEvent(JComponent.java:1753)
at java.awt.Component.processEvent(Component.java:2969)
at java.awt.Container.processEvent(Container.java:987)
at java.awt.Component.dispatchEventImpl(Component.java:2376)
at java.awt.Container.dispatchEventImpl(Container.java:1032)
at java.awt.Component.dispatchEvent(Component.java:2289)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:1944
)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:1721)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:1645)
at java.awt.Container.dispatchEventImpl(Container.java:1019)
at java.awt.Window.dispatchEventImpl(Window.java:714)
at java.awt.Component.dispatchEvent(Component.java:2289)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:258)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:68)
(Review ID: 84037)
======================================================================
Name: krT82822 Date: 10/07/99
When a JTable has
table.setAutoResizeMode(JTable.AUTO_RESIZE_NEXT_COLUMN);
set, and while trying to resize the last column to the right side,
the following exception happens:
java.lang.ArrayIndexOutOfBoundsException: 6 >= 6
at java.util.Vector.elementAt(Vector.java:409)
at javax.swing.table.DefaultTableColumnModel.getColumn(DefaultTableColumnModel.java:267)
at javax.swing.JTable.accommodateDelta(JTable.java:2025)
at javax.swing.table.DefaultTableColumnModel.fireColumnMarginChanged(DefaultTableColumnModel.java:532)
at javax.swing.table.DefaultTableColumnModel.propertyChange(DefaultTableColumnModel.java:564)
at javax.swing.event.SwingPropertyChangeSupport.firePropertyChange(SwingPropertyChangeSupport.java:157)
at javax.swing.table.TableColumn.firePropertyChange(TableColumn.java:228)
at javax.swing.table.TableColumn.firePropertyChange(TableColumn.java:234)
at javax.swing.table.TableColumn.setWidth(TableColumn.java:444)
at javax.swing.plaf.basic.BasicTableHeaderUI$MouseInputHandler.mouseDragged(BasicTableHeaderUI.java:137)
at java.awt.AWTEventMulticaster.mouseDragged(AWTEventMulticaster.java:263)
at java.awt.Component.processMouseMotionEvent(Component.java:3656)
at javax.swing.JComponent.processMouseMotionEvent(JComponent.java:2313)
at java.awt.Component.processEvent(Component.java:3445)
at java.awt.Container.processEvent(Container.java:1253)
at java.awt.Component.dispatchEventImpl(Component.java:2529)
at java.awt.Container.dispatchEventImpl(Container.java:1302)
at java.awt.Component.dispatchEvent(Component.java:2443)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:2504)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:2191)
at java.awt.Container.dispatchEventImpl(Container.java:1289)
at java.awt.Window.dispatchEventImpl(Window.java:854)
at java.awt.Component.dispatchEvent(Component.java:2443)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:302)
at java.awt.EventDispatchThread.pumpOneEvent(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:95)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:86)
(Review ID: 96247)
======================================================================