Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Swing repaint() not working / might be a case of RFM / tried a few things but can't get it to work

 
J Westland
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello -

repaint() does not work. Classic Swing problem, tried a few things I found online but it's not immediately clear to me...I tried validate, repaint, using a new thread, repainting the whole container all tips I found online but no joy.

If it's a case of RTFM feel free to post a link and tell me so :S

My training wheels are not off yet

I realize there are several problems with this code (comments, layout not right etc..) but it's still a WIP. I will refactor once the the functionality is there and add proper layout management, comments and JavaDoc.

For now, I just need to figure out why the update bit doesn't work



So, I call upDateTable(JTable newtable) via another class, I tested this gets called with a print statement.
The is just so I don't have to post all the other class code too (after al maybe the Table returned doesn't work but I tested that)
 
Rob Camick
Ranch Hand
Posts: 2703
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Creating a new JTable does NOT add the table to the GUI, it just creates an Object in memory. So the code should be:



However, even that is not the best approach. The best approach is to simply update the model of the table. So the code should be:



The table will update and repaint itself.
 
J Westland
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That worked, thank you

It just shows I haven't done much with Swing yet...well at least the xml/IO bits are working

Seems I was looking for something complicated, where it was simple ^_^
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!