How to run the program in maximum size in java ,so that it shows the restore button also, without using Toolkit t=Toolkit.getDefaultToolkit(); as it doesn't show RestoreDown Button
Asked
Active
Viewed 131 times
-3
-
What GUI are you using? `Swing`, `SWT`, `AWT` or other? – Usagi Miyamoto Aug 25 '17 at 14:29
-
i am using swing @UsagiMiyamoto – Harry Sandal Aug 25 '17 at 14:32
-
1Quit shouting! Bold is used to highlight a word or a phrase, not an entire question. – camickr Aug 25 '17 at 14:39
-
i'm a new user And i didn't know that thanks sir for guidance @camickr – Harry Sandal Aug 25 '17 at 14:53
3 Answers
0
frame.pack();
frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
frame.setVisible(true);

camickr
- 321,443
- 19
- 166
- 288
-
@UsagiMiyamoto, of course there is. I've been using it will Swing for a decade. – camickr Aug 25 '17 at 14:46
-
There is not. It is visible thru `JFrame`, as `JFrame extends Frame`. Most IDEs will hint you to use the declaring class... – Usagi Miyamoto Aug 25 '17 at 14:47
-
@UsagiMiyamoto who said you that go and use then talk ,you are here only for decrease others reputation like you have done with me and also with camickr sorry in advance if you get angry – Harry Sandal Aug 25 '17 at 14:50
-
@HarrySandal `But there is no use of frame.pack isn't it` - I use it in case the user clicks on the "minimuze" button. Then the frame will minimize to the packed size. If you don't do a pack() then it will minimize to just show the titlebar and borders. – camickr Aug 25 '17 at 17:40
-1
If by "run the program in maximum size" you mean open a JFrame
maximized, then try something like this:
setExtendedState(getExtendedState() | Frame.MAXIMIZED_BOTH);
See: https://docs.oracle.com/javase/8/docs/api/java/awt/Frame.html#setExtendedState-int-

Usagi Miyamoto
- 6,196
- 1
- 19
- 33
-
(1-) this answer was given earlier and there is no need to use the or condition. – camickr Aug 25 '17 at 14:47
-2
frame.setExtendedState(JFrame.MAXIMIZED_BOTH)
by using this we can make our screen open in maximize size and it also show us the button for resore-down which is not shown when we use lower one
Toolkit t=Toolkit.getDefaultToolkit();
Dimension d=t.getScreenSize();
frame.setLocation((d.width-900),(d.height-600));

Harry Sandal
- 43
- 11
-
(1-) this answer was given earlier. No need to clutter the forum with the same answer. – camickr Aug 25 '17 at 14:49
-
Ufff man first use it then say please ..............@UsagiMiyamoto and don't forget to up my reputation if I am Right – Harry Sandal Aug 25 '17 at 14:56
-