Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Iconifying on close

Iceman24Iceman24 Posts: 119Member
I'm trying to set my program so that instead of exiting on close button it will iconify, but for some reason when I say
setDefaultCloseOperation( WindowConstants.HIDE_ON_CLOSE )
it doesn't. It dissapears just the same as if I had called
setVisible( false )
I've tried doing the same method call with DO_NOTHING_ON_CLOSE and it works like the variable says: it does nothing. I'm connected remotely to a Unix system and I'm on XP. Maybe it's not able to put the icon in the start bar because of that? Any ideas? Owen

A humanitarian is always a hypocrite.
-George Orwell

Comments

  • You can do this with a WindowListener. setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE) and in the WindowListener's .windowClosing method setState(Frame.ICONIFIED).

    tron.

    : I'm trying to set my program so that instead of exiting on close button it will iconify, but for some reason when I say
    : setDefaultCloseOperation( WindowConstants.HIDE_ON_CLOSE )
    : it doesn't. It dissapears just the same as if I had called
    : setVisible( false )
    : I've tried doing the same method call with DO_NOTHING_ON_CLOSE and it works like the variable says: it does nothing. I'm connected remotely to a Unix system and I'm on XP. Maybe it's not able to put the icon in the start bar because of that? Any ideas? Owen
    :
    : A humanitarian is always a hypocrite.
    : -George Orwell
    :

  • Iceman24Iceman24 Posts: 119Member
    Thanks, I figured that out just before I checked for responses....figures :) Got another one though: I can get it to do the minimization now but the JFrame I'm iconifying contains a JScrollPane and contained within that is a JList. When I deiconify the window it fails to redisplay the contents of the JFrame. Do I need to put the scrollbar back into the window in the windowDeiconified method? Thanks.


    : You can do this with a WindowListener. setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE) and in the WindowListener's .windowClosing method setState(Frame.ICONIFIED).
    :
    : tron.
    :
    : : I'm trying to set my program so that instead of exiting on close button it will iconify, but for some reason when I say
    : : setDefaultCloseOperation( WindowConstants.HIDE_ON_CLOSE )
    : : it doesn't. It dissapears just the same as if I had called
    : : setVisible( false )
    : : I've tried doing the same method call with DO_NOTHING_ON_CLOSE and it works like the variable says: it does nothing. I'm connected remotely to a Unix system and I'm on XP. Maybe it's not able to put the icon in the start bar because of that? Any ideas? Owen
    : :
    : : A humanitarian is always a hypocrite.
    : : -George Orwell
    : :
    :
    :


    A humanitarian is always a hypocrite.
    -George Orwell

  • Well, that's quite a strange behaviour of Java. Never heard of that problem. Maybe you can fix it by calling the Frame's .repaint() method in
    .windowDeiconified if the child components are still existing at this point.

    I don't have any other suggestions right now. You might have a chance to find a better solution at suns java bug list (java.sun.com).

    tron.

    : Thanks, I figured that out just before I checked for responses....figures :) Got another one though: I can get it to do the minimization now but the JFrame I'm iconifying contains a JScrollPane and contained within that is a JList. When I deiconify the window it fails to redisplay the contents of the JFrame. Do I need to put the scrollbar back into the window in the windowDeiconified method? Thanks.
    :
    :
    : : You can do this with a WindowListener. setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE) and in the WindowListener's .windowClosing method setState(Frame.ICONIFIED).
    : :
    : : tron.
    : :
    : : : I'm trying to set my program so that instead of exiting on close button it will iconify, but for some reason when I say
    : : : setDefaultCloseOperation( WindowConstants.HIDE_ON_CLOSE )
    : : : it doesn't. It dissapears just the same as if I had called
    : : : setVisible( false )
    : : : I've tried doing the same method call with DO_NOTHING_ON_CLOSE and it works like the variable says: it does nothing. I'm connected remotely to a Unix system and I'm on XP. Maybe it's not able to put the icon in the start bar because of that? Any ideas? Owen
    : : :
    : : : A humanitarian is always a hypocrite.
    : : : -George Orwell
    : : :
    : :
    : :
    :
    :
    : A humanitarian is always a hypocrite.
    : -George Orwell
    :
    :

Sign In or Register to comment.