Solved

maximize JFrame

Posted on 2001-07-16
4
1,098 Views
Last Modified: 2008-02-01
how can i maximize a JFrame?
frame.setState does not offer maximize...

thnx
0
Comment
Question by:Hoffa
4 Comments
 
LVL 3

Accepted Solution

by:
Dmitriy earned 200 total points
ID: 6287299
unfortunately, as far as I know, there is no way to explicitly state the state of frame to MAXIMIZED.  If you want to maximize the frame on load, you can do so in a batch file:


start /max java ClassName.class

The /max will make the window maximized
0
 
LVL 19

Expert Comment

by:Jim Cakalic
ID: 6287326
There is currently no direct support for this. The best you can do is make sure the frame is deiconified then set its size to the screen size.

frame.setState(Frame.NORMAL);
Toolkit toolkit = Toolkit.getDefaultToolkit();
Dimension dimension = toolkit.getScreenSize();
frame.setSize(dimension);

Of course, the os will not treat this as a maximized frame, so in general this is a poor substitute for simulating maximize. Furthermore, on Windows this technique does not respect the toolbar. There are non-portable methods using JNI which I have used to do the same on Win32.

On the bright side, JDK 1.4 looks like it will provide direct support for this capability -- finally.

Best regards,
Jim Cakalic
0
 
LVL 16

Expert Comment

by:Valeri
ID: 6288893
L
0
 

Expert Comment

by:c2000
ID: 6289407

frame.setSize(Toolkit.getDefaultToolkit().getScreenSize());
is the simple way to mixize a JFrame. But if you want to maximize a JFrame instead of resizing it. You can use the new functions in the following link:
http://java.sun.com/j2se/1.4/docs/guide/awt/AWTChanges.html#fullscreen
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
jar file executable 12 52
Windows 10 IE Certificate Issue 10 45
java jdbc batch example 8 34
tomcat not starting 6 45
For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question