Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem in refreshing JPanels in cardlayout

 
partha phukan
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi...! i have a problem in refreshing JPanels in cardlayout. I have used cardlayout and i displayed separate informations in different JPanels. Now selecting each JMenuItems from the menuBar displays separate JPanels.

I have used three classes for this.....
1) A class containing the connections and the database queries.....
2) One main class......
3) Separate separate classes for the JPanels (which are in cardlayout) and these JPanels are then added to the main class, which contains the cardlayout........

Again in each JPanels(in cardlayout) there are JLabels and Graphs containing database values. Now my problem is that when i select different menuItems it displays the required JPanels, but it leaves the previous JPanel in that state in which i left.....

Let me explain properly.... For example in one JPanel there is a combobox, having list of Temperature, Rainfall, Wind. Now at first it displays Temperature Graph and if i select Rainfall then it displays Rainfall Graph. Working fine.... Now if i select another JMenuItem then it takes me to the respective JPanel, but it leaves the JPanel in that state where i left i.e when i again select JMenuItem (for the JPanel) then i found the JPanel with the Rainfall Graph but i need the JPanel with the Temperature Graph..... i.e the JPanels must got refreshed at each switching (of JPanels), by selecting JMenuItem

Probably i could explain you properly..... I have tried to use swing timers, but still not any progress........ Please suggest me..... please guide me........ Please give some valuabe information...... Any help will highly be appreciated.... Thanks
 
Rob Camick
Ranch Hand
Posts: 2534
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
but it leaves the previous JPanel in that state in which i left.....


Yes, that is the way it should work. You didn't change the state of any component on the panel so it should look exactly the same the next time you display the panel. As a user this is what I would expect.

If you want the panel to have different information, then you need to update the components on the panel with new information.
 
partha phukan
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for your reply. But would you please give me some hint or some suggestion about doing that. Please guide me.... i could not able to find a proper way of doing that. please....
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic