aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes How do you maximize on frame load? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How do you maximize on frame load?" Watch "How do you maximize on frame load?" New topic
Author

How do you maximize on frame load?

bobby, morkos
Ranch Hand

Joined: Jan 04, 2002
Posts: 82
I want to maximize by default when application load and to disable frame minimize icon button.
rom chatterjee
Ranch Hand

Joined: Dec 11, 2001
Posts: 46
Bobby
The following will give you the max size.
setSize(getToolkit().getScreenSize());
To capture the window minimising implement the WindowListener interface, or easier extend the WindowAdapter class and override the public void windowDeiconified(WindowEvent e) method.


Rom Chatterjee<BR>Sun Certified Java Programmer
Manfred Leonhardt
Ranch Hand

Joined: Jan 09, 2001
Posts: 1492
Hi Bobby,
Unfortunately overriding the windowIconified or windowDeiconified is not going to work because you only get called after the event has been acted upon.
Regards,
Manfred.
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

Use a Window (or JWindow) instead of a Frame (or JFrame)?

-Nate


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

Sorry for the tersness of the previous post... I was in a hurry yesterday (lots of work... deadlines... etc.) and I thought I would expand upon what I said...

Basically, you are asking two questions...
  • Is there a method to set the JFrame to maximized?

  • and...
  • Is there a way to disable JFrame minimization?


  • First, the maximization. The way this used to be done is just to set the size of the JFrame to the size of the screen. This mostly worked... the only real problem with it was the user could still press the maximize button to truly maximize the JFrame. But you could call setResizable( false ) on the frame so it couldn't change size in response to a user action, and as a by-product would disable the maximize button on the frame. However, Sun has added a way to really maximize a JFrame in the new Java 1.4! (in operating systems that support the idea of maximization... that is one of the reasons it wasn't included before...) -


    Okay, now on to the other question... how to disable minimization... there's no such method as setMinimizable( false ) or anything that disables the minimization button... and listening for minimization events with a WIndowListener is bogus because you can only respond to the minimization event and call setState( NORMAL ); to pop the Frame back up, which looks kinda funny.

    The only solution to both of these problems is to use a Window or JWindow. You can make a JWindow the size of the screen to 'maximize' it, and since there is no minimize button(or frame decorations at all!), the user will never be able to minimize it. There are really only two things to worry about -
  • Providing a way to exit the program, since the little x button isn't up there anymore...

  • and...
  • There isn't a button on the taskbar for it in windows, so there is no quick way to hop to it from another app, other than Alt-Tab, or clicking on a visible part of the window.


  • Hopefully, this has given you a bit more help than my last one-liner...

    -Nate
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: How do you maximize on frame load?