Solved

maximize JFrame

Posted on 2001-07-16
4
1,096 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
Comment Utility
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
Comment Utility
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
Comment Utility
L
0
 

Expert Comment

by:c2000
Comment Utility

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
IT Company 5 68
wordcount challenge 11 73
Modeling a class in java 5 31
bitbucket vs gitbucket 3 29
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

743 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

15 Experts available now in Live!

Get 1:1 Help Now