Meaningless Drivel is fun!*
The moose likes Swing / AWT / SWT and the fly likes Maximize JFrame from code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Maximize JFrame from code" Watch "Maximize JFrame from code" New topic
Author

Maximize JFrame from code

Marcus Rag
Greenhorn

Joined: Dec 23, 2009
Posts: 6
Hi there,

I am new to the forum, so I apologize for any daft moments :)

I searched for this topic and only got topic on disabling the maximize button, so here goes.

I need to set my jFrame (which is also my main class) to maximize in startup. To set it to be the same size as the screen is not good enough, because that means that someone might accidentally move it.

Any suggestions?

Thanks,
Marcus
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2191
    
    7
Marcus Rag
Greenhorn

Joined: Dec 23, 2009
Posts: 6
Thanks Rob,

but where in my code do I put this?

cheers
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2191
    
    7
Experiment. How long does it take to add that line of code in your program to see what it does.
Marcus Rag
Greenhorn

Joined: Dec 23, 2009
Posts: 6
I already have experimented...and it takes very long. I constantly get the error that the non-static method can not be referenced from a static contexted...
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19697
    
  20

Either call frame.setExtendedState(...) where frame is your JFrame instance, or call it inside an instance method of the JFrame. That's not so hard, is it?


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
> I constantly get the error that the non-static method can not be referenced from a static contexted...

I'd also suggest you forget about GUI's until you understand the fundamentals of the language.
and, no, Netbeans won't provide those.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Maximize JFrame from code