• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How do you maximize on frame load?

 
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to maximize by default when application load and to disable frame minimize icon button.
 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Use a Window (or JWindow) instead of a Frame (or JFrame)?

-Nate
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
     
    Consider Paul's rocket mass heater.
    reply
      Bookmark Topic Watch Topic
    • New Topic