File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes problem in refreshing JPanels in cardlayout Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "problem in refreshing JPanels in cardlayout" Watch "problem in refreshing JPanels in cardlayout" New topic
Author

problem in refreshing JPanels in cardlayout

partha phukan
Ranch Hand

Joined: Mar 13, 2011
Posts: 31
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

Joined: Jun 13, 2009
Posts: 2182
    
    7
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

Joined: Mar 13, 2011
Posts: 31
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....
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem in refreshing JPanels in cardlayout