-3

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

Harry Sandal
  • 43
  • 11

3 Answers3

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
-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