Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to minimize a JFrame window from Java?

In my Java app, I have a JFrame window, how can I minimize it from my Java program ?

like image 452
Frank Avatar asked Oct 19 '10 04:10

Frank


People also ask

How do you hide a frame window in Java?

For hiding a JFrame, setVisible(false) is correct (and again besides the deprecated hide() again the only way). Depending on if you plan to eventually reuse the frame (show it again in future) you may additionally want to additionally call dispose() if you will not show the frame again.

How do I change the size of a JFrame window?

setSize() and frame. pack() . You should use one of them at one time. Using setSize() you can give the size of frame you want but if you use pack() , it will automatically change the size of the frames according to the size of components in it.

How do you make a JFrame fit the screen?

Select all components of JFrame, right click, select 'Auto Resizing', check for both Horizontal and Vertical, close . Show activity on this post. Calling pack() will usually result in the window being resized to fit the contents' preferred size.

How do I close a Java window?

We can close the AWT Window or Frame by calling dispose() or System. exit() inside windowClosing() method. The windowClosing() method is found in WindowListener interface and WindowAdapter class.


1 Answers

minimize with frame.setState(Frame.ICONIFIED)

restore with frame.setState(Frame.NORMAL)

like image 137
Brad Mace Avatar answered Oct 05 '22 22:10

Brad Mace