Java Swing: JFrame Window Maximisation

C

Chris Smith

Whats said:
Toolkit.isFrameStateSupported(Frame.MAXIMIZED_BOTH);

this gives me a compile eror saying nonstatic method cannot be reference
from a static ontext blah blah

Yeah, I was assuming at least some fundamental knowledge of Java.
isFrameStateSupported is an instance method, not a static method, and
Toolkit instances are obtained from a static factory called
getDefaultToolkit(). So the actual code is:

Toolkit.getDefaultToolkit()
.isFrameStateSupported(Frame.MAXIMIZED_BOTH)

There's a piece of conventional wisdom that says that if you try to do
complex stuff like GUIs and you don't know the basics of the language,
you are asking for trouble. I might suggest you spend some time
learning basic Java with a good book, such as Bruce Eckel's TIJ book.

--
www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 
F

felixm

my report about the prob with setDefaultLookAndFeelDecorated(true):

import java.awt.*;
import javax.swing.*;

public class test extends JFrame
{
public test()
{
GraphicsEnvironment env =
GraphicsEnvironment.getLocalGraphicsEnvironment();
this.setMaximizedBounds(env.getMaximumWindowBounds ());
this.setExtendedState(this.getExtendedState() | this.MAXIMIZED_BOTH);
}

public static void main(String[] args)
{
JFrame.setDefaultLookAndFeelDecorated(true);

test t = new test();
t.setVisible(true);
}

Yes the "workaround" from Phaero works well... If you use a static taskbar... but with auto-hide taskbar, it is comprehensible that this trick cant work...
getMaximumWindowBounds returns the bounds of the whole screen and then it covers the toggling taskbar again...

I wanted to use the DefaultLookAndFeelDecorated window, because in Windows standard lnf, the sys menu doesnt fit in the metal lnf... or the metal lnf sys menu simply looks better. However, now I will use the native decorated windows... actually unimportant but I spent a lot of energy in prob^^

I use Windows XP and Java 1.5

regards... felixm
 
F

felixm

[QUOTE=Chris Smith]Whats up dog! said:
Toolkit.isFrameStateSupported(Frame.MAXIMIZED_BOTH);

this gives me a compile eror saying nonstatic method cannot be reference
from a static ontext blah blah

Yeah, I was assuming at least some fundamental knowledge of Java.
isFrameStateSupported is an instance method, not a static method, and
Toolkit instances are obtained from a static factory called
getDefaultToolkit().[/QUOTE]


Do you have the api doc??? if you program java you should use it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top