This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Reloding JPanel Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Reloding JPanel" Watch "Reloding JPanel" New topic
Author

Reloding JPanel

Mayur Gosalia
Ranch Hand

Joined: Jan 03, 2010
Posts: 54
Hi,

I have JPanel that is displaying some statistical figures, which are gathered from data in the database. All i want to do is have a refresh button that will refresh the Jpanel to show updates made yb the user. So basically i want to be able to reload/refresh the JPanel any ideas on how to do this?

Even better could i put al of code inside a timer or something and get it to re run the code every 30secs or something?

Thank You
pete stein
Bartender

Joined: Feb 23, 2007
Posts: 1561
Mayur Gosalia wrote:I have JPanel that is displaying some statistical figures, which are gathered from data in the database. All i want to do is have a refresh button that will refresh the Jpanel to show updates made yb the user. So basically i want to be able to reload/refresh the JPanel any ideas on how to do this?

I highly doubt that you want to "reload" the JPanel. Rather you'll want to update the data that it's displaying. How you do this depends entirely on how you are displaying that data, so there is no one-size fits all solution here. You're going to have to work this one out.

Even better could i put al of code inside a timer or something and get it to re run the code every 30secs or something?

A Swing Timer can do this, but perhaps better is if you can somehow listen for changes and change your display only after changes in data have occurred.
Mayur Gosalia
Ranch Hand

Joined: Jan 03, 2010
Posts: 54
the jpanel get some info from a function, which queries a reesultset, then passes all info to the main function. the main function then runs a series a if statements and changes colours of jlabels.

well i know when the data is updated, its when one of two buttons are clicked. But i cant workout how to reload the panel, any one of the many ideas that can help me do this would be appreciated.

pete stein
Bartender

Joined: Feb 23, 2007
Posts: 1561
Mayur Gosalia wrote:the jpanel get some info from a function, which queries a reesultset, then passes all info to the main function. the main function then runs a series a if statements and changes colours of jlabels.

well i know when the data is updated, its when one of two buttons are clicked. But i cant workout how to reload the panel, any one of the many ideas that can help me do this would be appreciated.



I know that based on the information give, I haven't the foggiest idea of how to help you. You may wish to tighten up your question a bit. A site that has helped me and can help you ask tighter more answerable questions is this one: How To ask Smart Questions

Much luck!
Mayur Gosalia
Ranch Hand

Joined: Jan 03, 2010
Posts: 54
never mind, i have sorted this one. Just used a timer to run iterate every 30secs..problem solved.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Reloding JPanel