wood burning stoves*
The moose likes Swing / AWT / SWT and the fly likes Jtable added row doesnt show after compiling and running the program Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Jtable added row doesnt show after compiling and running the program" Watch "Jtable added row doesnt show after compiling and running the program" New topic
Author

Jtable added row doesnt show after compiling and running the program

Gabor Beke
Greenhorn

Joined: Jul 11, 2012
Posts: 16
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: 2176
    
  47
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: 16
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: 38075
    
  22
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: 154
- 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: 16
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: 16
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: 2176
    
  47
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
 
Similar Threads
JTable
JTable(!!!)
JTable Runtime Addition
JTable
Jtable