| Author |
Jtable added row doesnt show after compiling and running the program
|
Gabor Beke
Greenhorn
Joined: Jul 11, 2012
Posts: 14
|
|
Hi there!
I have jtable with rows added dynamicly by vectors. In netbeans its working when I add new row to my jtable, but when I compile my program and run the jar file it doesnt work, its show up only when I hold down the left mouse button and moving over the jtable then the new rows are drawned. What's wrong? what am I missing?
I use
to add a new row to my jtable by a Jbutton that has actionlistener for it. in netbeans when I run it its working. How come in netbeans its working then when I compile it ,its not?
|
 |
Tony Docherty
Bartender
Joined: Aug 07, 2007
Posts: 1152
|
|
|
The code you have shown is insufficient to be able to answer your question, can you provide an SSCCE or at the very least details of the table model you are using.
|
 |
Gabor Beke
Greenhorn
Joined: Jul 11, 2012
Posts: 14
|
|
First of all thank you for answering. Here's all the part of the code with jtable.
And the TableColumnAdjuster java (that makes columns autosize its wide according the text length)
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32644
|
|
Moving to our GUIs forum.
And please read about line length here. Your lines are too long and that can make the code difficult to read.
|
 |
m Korbel
Ranch Hand
Joined: Jun 19, 2012
Posts: 69
|
|
- your DefaultTableModel is based on Vector Vector colNames = new Vector();,
- then add a new row required array by using Vector, not String[] row = {name.getText(), product.getText(), price.getText() , campaign.getText()};
- [],%20java.lang.Object[]%29]Change model to Array
- change array String[] row = {name.getText(), product.getText(), price.getText() , campaign.getText()}; to Vector
|
 |
Gabor Beke
Greenhorn
Joined: Jul 11, 2012
Posts: 14
|
|
its still not working even I've changed it to vector, the jtable rows arent drawned after compiling it and running the jar file. Altough in netbeans its working. How come? I found it out!
My table column adjuster caused the problem, can somebody check for me why isnt working with it?
|
 |
Gabor Beke
Greenhorn
Joined: Jul 11, 2012
Posts: 14
|
|
|
I resolved it. I copied TableColumnAdjuster java content to my main java file, and its working now, although I dont know why It cant access to it if its in another class file. Thank you all.
|
 |
Tony Docherty
Bartender
Joined: Aug 07, 2007
Posts: 1152
|
|
|
If the problem was it couldn't find the class then a exception should have been thrown which would have dumped the stack trace to the console (unless you are catching and ignoring exceptions in your code).
|
 |
 |
|
|
subject: Jtable added row doesnt show after compiling and running the program
|
|
|