• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Reloding JPanel

 
Mayur Gosalia
Ranch Hand
Posts: 54
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1561
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 54
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1561
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 54
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
never mind, i have sorted this one. Just used a timer to run iterate every 30secs..problem solved.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic