Solved

maximize JFrame

Posted on 2001-07-16
4
1,097 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
My project did see openJDK that I installed. What could be the problem 7 122
Java and GPO 11 68
Java - Why doesn't this JFrame work 3 41
eclipse java  build path 6 44
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…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
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:

911 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now