Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4089573

Swing 0.5 JTable getValueAt called with -1 columnIndex

XMLWordPrintable

    • swing0.7
    • x86
    • windows_nt



      Name: joT67522 Date: 10/29/97


      I am using Swing 0.5 JTable with the DefaultTable Model.
      The application contains the following panels:

      JFrame containing
          JPanel containing
             JDesktopPane containing
                 JInternalFrame containing
                     JScrollPane containing
                         JTable

      The JTable getValueAt() method is being called with
      a -1 for the columnIndex. This happens both when I
      use my own TableModel and when I use the DefaultTableModel.
      Below is the stack trace when using the DefaultTableModel.

      import com.sun.java.swing.*;
      import com.sun.java.swing.table.*;
      import java.awt.*;
      import java.util.Vector;

      public class mainFrame extends JFrame
      {
          JDesktopPane lc;
          JPanel mainPanel;
          
          
          public static void main(String argv[])
          {
                  // Create the main frame
                // new mainFrame().show();
                  new mainFrame();
          }
          
          public mainFrame(){
              getContentPane().setLayout(new BorderLayout());
              mainPanel = new JPanel();
              mainPanel.setLayout(new BorderLayout());
              getContentPane().add("Center", mainPanel);
              lc = new JDesktopPane();
                  lc.setOpaque(true);
                      resize(insets().left + insets().right + 900,insets().top + insets().bottom + 700);
              mainPanel.add("Center", lc);
              mainPanel.show();
                      intFrame newframe = new intFrame();
      System.out.println("mainFrame:NewFrame: got a new frame: " + newframe);
              lc.add(newframe);
              mainPanel.validate();
                      show();
                      newframe.show();
                      mainPanel.show();
          }
      }

      class intFrame extends JInternalFrame
      {

              JScrollPane scrollpane;
              JTable subsystemTable;
              TableColumnModel subsystemTableColumnModel;
              JTable diskTable;
              TableColumnModel diskTableColumnModel;


              public intFrame() {


                  final Object subsystemColumnHeader[] =
                  {"A",
                  "B",
                  "C"};
                  final Object diskColumnHeader[] =
                  {"A",
                  "B",
                  "C",
                  "D"};

                      setClosable(true);
                      setMaximizable(true);
                      setIconifiable(true);
                      setResizable(true);
                      setBounds(20,20,650,450);
                      try { setSelected(true); } catch (java.beans.PropertyVetoException e2) {}

                      getContentPane().setLayout(null);

                      // Create the subsystem table data model
                      subsystemTable = new com.sun.java.swing.JTable();
                      subsystemTable.setMultipleSelectionAllowed(false);
                  subsystemTable.setAutoCreateColumnsFromModel(false);

                      // Added our columns into the column model
                      for (int columnIndex = 0; columnIndex < subsystemColumnHeader.length; columnIndex++){
                              // Create a column object for each column of data
                              TableColumn newColumn = new TableColumn(subsystemColumnHeader[columnIndex]);
                              subsystemTable.addColumn(newColumn);
                      }

                      // Put the table and header into a scrollPane
                      JScrollPane subsystemScrollpane = JTable.createScrollPaneForTable(subsystemTable);
                      subsystemScrollpane.setBounds(insets().left + 260,insets().top + 36,350,150);
                      getContentPane().add(subsystemScrollpane);


                      // Create the disk table data model

                      diskTable = new JTable();

                      // Added our columns into the column model
                      for (int columnIndex = 0; columnIndex < diskColumnHeader.length; columnIndex++){

                              // Create a column object for each column of data
                               TableColumn newColumn = new TableColumn(diskColumnHeader[columnIndex]);
                               diskTable.addColumn(newColumn);
                      }


                      // Put the table and header into a scrollPane
                      JScrollPane diskScrollpane = JTable.createScrollPaneForTable(diskTable);
                      diskScrollpane.setBounds(insets().left + 260,insets().top + 186,350,150);
                      getContentPane().add(diskScrollpane);

              // Add data to the table
                      Vector subsystemTableData = new Vector();
                      String subsystem = new String("System");
                      subsystemTableData.addElement(subsystem);
                      subsystemTableData.addElement("Foo");
                      subsystemTableData.addElement("Bar");
                  // Add a row
                      subsystemTable.addRow(subsystemTableData);
                      // Add a row
                      subsystemTable.addRow(subsystemTableData);


              }
      }

      Exception occurred during event dispatching:
      java.lang.ArrayIndexOutOfBoundsException: -1 < 0
              at java.util.Vector.elementAt(Vector.java:326)
              at com.sun.java.swing.table.DefaultTableModel.getValueAt(DefaultTableMod
      el.java:1065)
              at com.sun.java.swing.JTable.getValueAt(JTable.java:953)
              at com.sun.java.swing.basic.BasicTableUI.prepareRenderer(BasicTableUI.ja
      va:395)
              at com.sun.java.swing.basic.BasicTableUI.drawRowInClipRect(BasicTableUI.
      java:333)
              at com.sun.java.swing.basic.BasicTableUI.paint(BasicTableUI.java:223)
              at com.sun.java.swing.JComponent.paintComponent(JComponent.java:341)
              at com.sun.java.swing.JComponent.paint(JComponent.java:507)
              at com.sun.java.swing.JComponent.paintChildren(JComponent.java:397)
              at com.sun.java.swing.JComponent.paint(JComponent.java:510)
              at com.sun.java.swing.JViewport.paint(JViewport.java:230)
              at com.sun.java.swing.JComponent.paintChildren(JComponent.java:397)
              at com.sun.java.swing.JComponent.paint(JComponent.java:510)
              at com.sun.java.swing.JComponent.paintChildren(JComponent.java:397)
              at com.sun.java.swing.JComponent.paint(JComponent.java:510)
              at com.sun.java.swing.JComponent.paintChildren(JComponent.java:397)
              at com.sun.java.swing.JComponent.paint(JComponent.java:510)
              at com.sun.java.swing.JLayeredPane.paint(JLayeredPane.java:360)
              at com.sun.java.swing.JComponent.paintChildren(JComponent.java:397)
              at com.sun.java.swing.JComponent.paint(JComponent.java:510)
              at com.sun.java.swing.JComponent.paintChildren(JComponent.java:397)
              at com.sun.java.swing.JComponent.paint(JComponent.java:510)
              at com.sun.java.swing.JComponent.paintChildren(JComponent.java:397)
              at com.sun.java.swing.JComponent.paint(JComponent.java:510)
              at com.sun.java.swing.JLayeredPane.paint(JLayeredPane.java:360)
              at com.sun.java.swing.JComponent.paintChildren(JComponent.java:397)
              at com.sun.java.swing.JComponent.paint(JComponent.java:510)
              at com.sun.java.swing.JComponent.paintChildren(JComponent.java:397)
              at com.sun.java.swing.JComponent.paint(JComponent.java:495)
              at com.sun.java.swing.JComponent.paintChildren(JComponent.java:397)
              at com.sun.java.swing.JComponent.paint(JComponent.java:510)
              at com.sun.java.swing.JLayeredPane.paint(JLayeredPane.java:360)
              at com.sun.java.swing.JComponent.paintChildren(JComponent.java:397)
              at com.sun.java.swing.JComponent.paint(JComponent.java:510)
              at java.awt.Container.paint(Container.java:645)
              at java.awt.Component.dispatchEventImpl(Component.java:1412)
              at java.awt.Container.dispatchEventImpl(Container.java:837)
              at java.awt.Window.dispatchEventImpl(Window.java:401)
              at java.awt.Component.dispatchEvent(Component.java:1393)
              at java.awt.EventDispatchThread.run(EventDispatchThread.java:63)
      Exception occurred during event dispatching:
      java.lang.ArrayIndexOutOfBoundsException: -1 < 0
              at java.util.Vector.elementAt(Vector.java:326)
              at com.sun.java.swing.table.DefaultTableModel.getValueAt(DefaultTableMod
      el.java:1065)
              at com.sun.java.swing.JTable.getValueAt(JTable.java:953)
              at com.sun.java.swing.basic.BasicTableUI.prepareRenderer(BasicTableUI.ja
      va:395)
              at com.sun.java.swing.basic.BasicTableUI.drawRowInClipRect(BasicTableUI.
      java:333)
              at com.sun.java.swing.basic.BasicTableUI.paint(BasicTableUI.java:223)
              at com.sun.java.swing.JComponent.paintComponent(JComponent.java:341)
              at com.sun.java.swing.JComponent.paint(JComponent.java:507)
              at com.sun.java.swing.JComponent.paintChildren(JComponent.java:397)
              at com.sun.java.swing.JComponent.paint(JComponent.java:510)
              at com.sun.java.swing.JViewport.paint(JViewport.java:230)
              at com.sun.java.swing.JComponent.paintChildren(JComponent.java:397)
              at com.sun.java.swing.JComponent.paint(JComponent.java:510)
              at com.sun.java.swing.JComponent.paintChildren(JComponent.java:397)
              at com.sun.java.swing.JComponent.paint(JComponent.java:510)
              at com.sun.java.swing.JComponent.paintChildren(JComponent.java:397)
              at com.sun.java.swing.JComponent.paint(JComponent.java:510)
              at com.sun.java.swing.JLayeredPane.paint(JLayeredPane.java:360)
              at com.sun.java.swing.JComponent.paintChildren(JComponent.java:397)
              at com.sun.java.swing.JComponent.paint(JComponent.java:510)
              at com.sun.java.swing.JComponent.paintChildren(JComponent.java:397)
              at com.sun.java.swing.JComponent.paint(JComponent.java:510)
              at com.sun.java.swing.JComponent.paintChildren(JComponent.java:397)
              at com.sun.java.swing.JComponent.paint(JComponent.java:510)
              at com.sun.java.swing.JLayeredPane.paint(JLayeredPane.java:360)
              at com.sun.java.swing.JComponent.paintChildren(JComponent.java:397)
              at com.sun.java.swing.JComponent.paint(JComponent.java:510)
              at com.sun.java.swing.JComponent.paintChildren(JComponent.java:397)
              at com.sun.java.swing.JComponent.paint(JComponent.java:495)
              at com.sun.java.swing.JComponent.paintChildren(JComponent.java:397)
              at com.sun.java.swing.JComponent.paint(JComponent.java:510)
              at com.sun.java.swing.JLayeredPane.paint(JLayeredPane.java:360)
              at com.sun.java.swing.JComponent._paintImmediately(JComponent.java:2745)

              at com.sun.java.swing.JComponent.paintImmediately(JComponent.java:2661)
              at com.sun.java.swing.RepaintManager.paintDirtyRegions(RepaintManager.ja
      va:283)
              at com.sun.java.swing.RepaintManager.actionPerformed(RepaintManager.java
      :214)
              at com.sun.java.swing.Timer.fireActionPerformed(Timer.java:113)
              at com.sun.java.swing.Timer$DummyComponent.processEvent(Timer.java:288)
              at java.awt.Component.dispatchEventImpl(Component.java:1456)
              at java.awt.Component.dispatchEvent(Component.java:1393)
              at java.awt.EventDispatchThread.run(EventDispatchThread.java:63)
      Exception occurred during event dispatching:
      java.lang.ArrayIndexOutOfBoundsException: -1 < 0
              at java.util.Vector.elementAt(Vector.java:326)
              at com.sun.java.swing.table.DefaultTableModel.getValueAt(DefaultTableMod
      el.java:1065)
              at com.sun.java.swing.JTable.getValueAt(JTable.java:953)
              at com.sun.java.swing.basic.BasicTableUI.prepareRenderer(BasicTableUI.ja
      va:395)
              at com.sun.java.swing.basic.BasicTableUI.drawRowInClipRect(BasicTableUI.
      java:333)
              at com.sun.java.swing.basic.BasicTableUI.paint(BasicTableUI.java:223)
              at com.sun.java.swing.JComponent.paintComponent(JComponent.java:341)
              at com.sun.java.swing.JComponent.paint(JComponent.java:507)
              at com.sun.java.swing.JComponent.paintChildren(JComponent.java:397)
              at com.sun.java.swing.JComponent.paint(JComponent.java:510)
              at com.sun.java.swing.JViewport.paint(JViewport.java:230)
              at com.sun.java.swing.JComponent.paintChildren(JComponent.java:397)
              at com.sun.java.swing.JComponent.paint(JComponent.java:510)
              at com.sun.java.swing.JComponent.paintChildren(JComponent.java:397)
              at com.sun.java.swing.JComponent.paint(JComponent.java:510)
              at com.sun.java.swing.JComponent.paintChildren(JComponent.java:397)
              at com.sun.java.swing.JComponent.paint(JComponent.java:510)
              at com.sun.java.swing.JLayeredPane.paint(JLayeredPane.java:360)
              at com.sun.java.swing.JComponent.paintChildren(JComponent.java:397)
              at com.sun.java.swing.JComponent.paint(JComponent.java:510)
              at com.sun.java.swing.JComponent.paintChildren(JComponent.java:397)
              at com.sun.java.swing.JComponent.paint(JComponent.java:510)
              at com.sun.java.swing.JComponent.paintChildren(JComponent.java:397)
              at com.sun.java.swing.JComponent.paint(JComponent.java:510)
              at com.sun.java.swing.JLayeredPane.paint(JLayeredPane.java:360)
              at com.sun.java.swing.JComponent.paintChildren(JComponent.java:397)
              at com.sun.java.swing.JComponent.paint(JComponent.java:510)
              at com.sun.java.swing.JComponent.paintChildren(JComponent.java:397)
              at com.sun.java.swing.JComponent.paint(JComponent.java:495)
              at com.sun.java.swing.JComponent.paintChildren(JComponent.java:397)
              at com.sun.java.swing.JComponent.paint(JComponent.java:510)
              at com.sun.java.swing.JLayeredPane.paint(JLayeredPane.java:360)
              at com.sun.java.swing.JComponent.paintChildren(JComponent.java:397)
              at com.sun.java.swing.JComponent.paint(JComponent.java:510)
              at java.awt.Container.paint(Container.java:645)
              at java.awt.Component.dispatchEventImpl(Component.java:1412)
              at java.awt.Container.dispatchEventImpl(Container.java:837)
              at java.awt.Window.dispatchEventImpl(Window.java:401)
              at java.awt.Component.dispatchEvent(Component.java:1393)
              at java.awt.EventDispatchThread.run(EventDispatchThread.java:63)
      (Review ID: 18852)
      ======================================================================

            erapinsunw Eric Rapin (Inactive)
            johsunw Joon Oh (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: