Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Repainting Problem(please help)  RSS feed

 
john von
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Really need your help guys, im working on this for days now. I created sort of mock up of what im really actually doing. Im really working on a Table and a Spit Pane. Just to present to you as brief as possible i wrote a two table instead. The real issue is I can't seems to resolve on repainting a panel. The buttons are located in another class, while the panel to repaint is in separate class. When i click a the button one, it should present the table one and button two on table two. .

I really appreciate any help. Here are the codes of 3 classes. You may ignore the table model method below




[ July 23, 2004: Message edited by: john von ]
 
Aaron Roberts
Ranch Hand
Posts: 174
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your code won't work because it doesn't ever change the tables.

You can't just change onTable and have the JFrame automatically change too. You need to remove the current JTable from the contentPane and then add the one you are trying to show.

Another, possibly easier way to do this, is use a CardLayout manager. It will let you swap the entire panel, regardless of how many components you add to it.

You also don't need to explicitly create a JPanel and then do a setContentPane. Just do a getContentPane() and add your components to it. Saves creating a JPanel.

HTH!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!