java.lang.IllegalArgumentException
It appears that I am passing an illegal or inappropriate argument, be darned if I can figure it out.
Anyone have any ideas?
The error occurs at getValueAt(), first listing.
The data and getter methods are in the second listing below.
Thank you.
JS.
publicclass TableDemoextends JPanel{
privateboolean DEBUG =false;
private StringBuffer sbOne=new StringBuffer("initsbOne");
private StringBuffer sbTwo=new StringBuffer("initsbTwo");
private StringBuffer sbThree =new StringBuffer("initsbThree");
private StringBuffer sbFour =new StringBuffer("initsbFour");
private StringBuffer sbFive =new StringBuffer("initsbFive");
private StringBuffer sbSix=new StringBuffer("initsbSix");
public TableDemo(){
super(new GridLayout(1,0));
JTable table =new JTable(new MyTableModel());// Original code
table.setPreferredScrollableViewportSize(new Dimension(500, 70));
//Create the scroll pane and add the table to it.
JScrollPane scrollPane =new JScrollPane(table);
//Add the scroll pane to this panel.
add(scrollPane);
}
publicclass MyTableModelextends AbstractTableModel{
ArrayList datalist =new ArrayList();
itemFile Obj_One =new itemFile(sbOne, sbTwo, sbThree,
sbFour, sbFive, sbSix);
public MyTableModel(){
datalist.add(0, Obj_One);
}
String[] columnNames ={"One","Two",
"Three",
"Four",
"Five"};
publicint getColumnCount(){
return columnNames.length;
}
publicint getRowCount(){
return datalist.size();
}
public String getColumnName(int col){
return columnNames[col];
}
public Object getValueAt(int row,int col){
itemFile obj = (itemFile)datalist.get( row );
switch( col ){
case 1 :return obj.getOne();
/*case 2 : return obj.getTwo();
case 3 : return obj.getThree();
case 4 : return obj.getFour();
case 5 : return obj.getFive();
case 6 : return obj.getSix();
*/
}
thrownew IllegalArgumentException( );
}
/*
* itemFile.java
*
* Created on June 12, 2006, 3:26 PM
*/
package masterfilemaint;
import java.io.*;
import java.lang.String;
/**
*
* @author jspence
*/
publicclass itemFileimplements Serializable{
private StringBuffer sbOne=new StringBuffer("defaultOne");
private StringBuffer sbTwo=new StringBuffer("defaultTwo");
private StringBuffer sbThree =new StringBuffer("defaultThree");
private StringBuffer sbFour =new StringBuffer("defaultFour");
private StringBuffer sbFive =new StringBuffer("defaultFive");
private StringBuffer sbSix=new StringBuffer("defaultSix");
private StringBuffer tempBuff =new StringBuffer("tempBuff");
private ObjecttempObject =new Object();
public itemFile(){}
public itemFile(StringBuffer one, StringBuffer two,
StringBuffer three, StringBuffer four,
StringBuffer five, StringBuffer six){
sbOne = one; sbTwo = two; sbThree = three;
sbFour = four; sbFive = five; sbSix = six;
}
public Object getOne(){
tempBuff = this.sbOne;
tempObject = (Object)tempBuff;
return tempObject;
}
public StringBuffer getTwo(){
return this.sbTwo;
}
public StringBuffer getThree(){
return this.sbThree;
}
public StringBuffer getFour(){
return this.sbFour;
}
public StringBuffer getFive(){
return this.sbFive;
}
public StringBuffer getSix(){
return this.sbSix;
}
}
[8132 byte] By [
jSpencea] at [2007-11-26 19:51:03]

All of the activity seems to be at the 'throw' clause a few lines below getValueAt().
java.lang.IllegalArgumentException
at tabledemo.TableDemo$MyTableModel.getValueAt(TableDemo.java:91)
at javax.swing.JTable.getValueAt(JTable.java:1771)
at javax.swing.JTable.prepareRenderer(JTable.java:3724)
at javax.swing.plaf.basic.BasicTableUI.paintCell(BasicTableUI.java:1149)
at javax.swing.plaf.basic.BasicTableUI.paintCells(BasicTableUI.java:1051)
at javax.swing.plaf.basic.BasicTableUI.paint(BasicTableUI.java:974)
at javax.swing.plaf.ComponentUI.update(ComponentUI.java:142)
at javax.swing.JComponent.paintComponent(JComponent.java:541)
at javax.swing.JComponent.paint(JComponent.java:808)
at javax.swing.JComponent.paintWithOffscreenBuffer(JComponent.java:4787)
at javax.swing.JComponent.paintDoubleBuffered(JComponent.java:4740)
at javax.swing.JComponent._paintImmediately(JComponent.java:4685)
at javax.swing.JComponent.paintImmediately(JComponent.java:4488)
at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:410)
at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:117)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:178)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:454)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)
java.lang.IllegalArgumentException
at tabledemo.TableDemo$MyTableModel.getValueAt(TableDemo.java:91)
at javax.swing.JTable.getValueAt(JTable.java:1771)
at javax.swing.JTable.prepareRenderer(JTable.java:3724)
at javax.swing.plaf.basic.BasicTableUI.paintCell(BasicTableUI.java:1149)
at javax.swing.plaf.basic.BasicTableUI.paintCells(BasicTableUI.java:1051)
at javax.swing.plaf.basic.BasicTableUI.paint(BasicTableUI.java:974)
at javax.swing.plaf.ComponentUI.update(ComponentUI.java:142)
at javax.swing.JComponent.paintComponent(JComponent.java:541)
at javax.swing.JComponent.paint(JComponent.java:808)
at javax.swing.JComponent.paintChildren(JComponent.java:647)
at javax.swing.JComponent.paint(JComponent.java:817)
at javax.swing.JViewport.paint(JViewport.java:722)
at javax.swing.JComponent.paintChildren(JComponent.java:647)
at javax.swing.JComponent.paint(JComponent.java:817)
at javax.swing.JComponent.paintChildren(JComponent.java:647)
at javax.swing.JComponent.paint(JComponent.java:817)
at javax.swing.JComponent.paintChildren(JComponent.java:647)
at javax.swing.JComponent.paint(JComponent.java:817)
at javax.swing.JLayeredPane.paint(JLayeredPane.java:557)
at javax.swing.JComponent.paintChildren(JComponent.java:647)
at javax.swing.JComponent.paintWithOffscreenBuffer(JComponent.java:4794)
at javax.swing.JComponent.paintDoubleBuffered(JComponent.java:4740)
at javax.swing.JComponent.paint(JComponent.java:798)
at java.awt.GraphicsCallback$PaintCallback.run(GraphicsCallback.java:21)
at sun.awt.SunGraphicsCallback.runOneComponent(SunGraphicsCallback.java:60)
at sun.awt.SunGraphicsCallback.runComponents(SunGraphicsCallback.java:97)
at java.awt.Container.paint(Container.java:1312)
at sun.awt.RepaintArea.paint(RepaintArea.java:177)
at sun.awt.windows.WComponentPeer.handleEvent(WComponentPeer.java:260)
at java.awt.Component.dispatchEventImpl(Component.java:3678)
at java.awt.Container.dispatchEventImpl(Container.java:1627)
at java.awt.Window.dispatchEventImpl(Window.java:1606)
at java.awt.Component.dispatchEvent(Component.java:3477)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:456)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)
BUILD SUCCESSFUL (total time: 3 seconds)