• Post Reply Bookmark Topic Watch Topic
  • New Topic

JPanel Problem

 
Peter Harvey
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have the following problem with a JPanel:
I am currently getting information from a database and displaying it in a JTable. Rather than make my own TableModel, I simply create a new JTable, remove the old JTable, and put the new one in its place.
In order to do this, I set the first JTable to null, call the JPanel's repaint method to get rid of it, add the new JTable, and call repaint again to show it. The problem is, the new JTable doesn't appear unless I click somewhere on the application. I've tried using a Graphics object to repaint it manually, but it tells me that those methods are protected and that I don't have access to them, even though I'm using an instance JPanel.
What am I doing wrong? I can't figure it out.
 
Mo Ibrahim
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
May be you can try invalidate() and call validate() again.
 
Peter Harvey
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It did the trick! Thanks!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!