File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Jtable added row doesnt show after compiling and running the program

 
Gabor Beke
Greenhorn
Posts: 16
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 2878
59
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 16
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 47274
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 174
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
- 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
Posts: 16
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 16
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 2878
59
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic