Sir/ Madam, i am facing a problem and i do not have any idea how to do. i face a problem regarding how to refresh a JPanel in a timely manner. I have three JLabel in a JPanel which get value from database. now my database is maintaining a table where i have values in a timely manner within an interval of 1 hour. now i have to refresh my JLabel values i.e refresh JPanel so that as time changes i can display the new data from the database.
For example- when time is 09:00:00 then i must display the data of 09:00:00 in JLabels, but as soon time changes to 10:00:00 then i need to display the 10:00:00 datas in JLabels. In between 09:00:00 to 09:59:59 the data must remain same i.e JLabels should display the 09:00:00 data. Only when it changes to 10:00:00 then only the JLabel should be modified with 10:00:00 data and it must remain same till 10:59:59.
Please, help me in this regard. Any help from you will highly be appreciated. Thank you in advance.
Thank you Sir for your suggestion, but i do not have any idea that what must be the time delay i should give. can i use repaint() method? again i want to ask you something whether i have to declare my query to retrieve data in the action performed method?
please sir, help me here. i know little about timers and schedule. please give me some suggestion or some link so that i can proceed further...
I havent used Timer myself. The delay would depend on how often you want the action to be performed. You can call the revalidate() method on JLabel object. Querying for data on a frequent basis might have performance impact. But again it depends on the requirements- If you have to fetch the fresh data after some interval then you would have to call the method which fetches the data with in the Action listener for the Timer.
Sir, still i cannot able to find the right track that where to use timers and what will be the delay to be set. i have two seperate classes-
1. One class that reads the data from the database and display in the JLabels.
2.Another separate class with queries and methods that return the data from the DB.
Now where to use timers? I am confused. please give me some suggestion.
posted 8 years ago
hello everyone, i am using a JPanel and there i have displayed two graphs. Now my problem is that i could not able to display them properly. I am using BorderLayout, but still i can not able to display them properly. can anyone help me and give me some suggestion that which layout i should use to display the graphs.
partha phukan wrote:hello everyone, i am using a JPanel and there i have displayed two graphs. Now my problem is that i could not able to display them properly. I am using BorderLayout, but still i can not able to display them properly. can anyone help me and give me some suggestion that which layout i should use to display the graphs.