Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I refresh or reload the JFrame? [closed]

Tags:

java

swing

jframe

I am doing project using Java and in that I need to reload whole JFrame after clicking particular button on that JFrame. How to do this?

like image 455
SL_User Avatar asked Oct 02 '11 17:10

SL_User


People also ask

How do you refresh code in Java?

The simplest way to achieve this in Java is using Action by extending AbstractAction . The methods you need to call to update your application are invalidate() , validate() or repaint() .

Which method is used to close the JFrame?

EXIT_ON_CLOSE (defined in JFrame) : Exit the application using the System exit method. Use this only in applications. might still be useful: You can use setVisible(false) on your JFrame if you want to display the same frame again. Otherwise call dispose() to remove all of the native screen resources.

How do I close a JFrame without exiting?

Use anything for setDefaultCloseOperation excepting EXIT_ON_CLOSE . Then, for the cancel button, just dispose() the window. If the application has another running thread, it won't exit. You can also hide a window by calling setVisible(false) .


1 Answers

Try

SwingUtilities.updateComponentTreeUI(frame); 

If it still doesn't work then after completing the above step try

frame.invalidate(); frame.validate(); frame.repaint(); 
like image 61
Alim Ul Gias Avatar answered Sep 21 '22 14:09

Alim Ul Gias