🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.swing
Article #11521

Re: JInternalFrame prevent from Closing

#11521
From: Rodolfo Botto
Date: Tue, 18 May 1999 00:00
76 lines
2894 bytes
The best way to do this is to install a VetoableChangeListener to the
internalFrame.
Something like the following code may work to you.

 internalFrame.addetoableChangeListener(new VetoableChangeListener() {
   public
   void vetoableChange(PropertyChangeEvent evt)
    throws PropertyVetoException
   {
    if (evt.getPropertyName().equals(JInternalFrame.IS_CLOSED_PROPERTY)) {

      if (new MessageDialog()) this.setVisible(false);
      else {
      throw new PropertyVetoException("Cannot Close", evt);
    }

     }
    }
 );


Michael H�rtig wrote:

> Hi all
>
> I have a problem with my JInternalFrame. If the user select Close from
> System-Menu (X) I want to ask if he is sure or not. I added a
> InternalFrameListener and set the DefaultCloseOperation. But how can I
> say NO, don't close???? The Frame always closes.
>
> Here my code..
>
> public MyInternalFrame(){
>   ...
>   this.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
>   this.addInternalFrameListener(new InternalFrameAdapter(){
>     public void internalFrameClosing(InternalFrameEvent ev){
>       //Here is a call of a Dialog that returns true (Yes, close) or
> false (No, not close)
>       if (new MessageDialog()) this.setVisible(false);
>       else return; //Doesnt work
>     }
>   });
>   ...
> }
>
> Hoping for help
>
> Michael
> --
>            ////
>           (o o)
> +-----ooO--(_)--Ooo---------------------------------------+
> |                                                         |
> | Michael H�rtig                 Neumann & Partner        |
> |                                Informationssysteme GmbH |
> | Softwareentwicklung            An der Hohen Stra�e 1    |
> |                                08393 Meerane            |
> |                                                         |
> +------------Oooo-----------------------------------------+
>         oooO (  )
>         (  )  (_)
>          (_)

--

Saludos.
Rodolfo Botto.


===========================================================
Rodolfo Botto                       IdeaSoft
Gabriel Pereira 2941 - CP 11300     icq# 18349112
Montevideo - Uruguay                Tel  : +5982 - 709 2590
http://www.isoft.com.uy             Fax  : +5982 - 709 2805
===========================================================
Technical Details
Message-ID: <374215C5.ED0DCC1A@isoft.com.uy>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <37414795.ABE6F2A3@nupis.de>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: 111d45,4fdaf2d63db86e3c,start
X-Google-Attributes: gid111d45,public
From: Rodolfo Botto <rbotto@isoft.com.uy>
Subject: Re: JInternalFrame prevent from Closing
Date: 1999/05/18
Message-ID: <374215C5.ED0DCC1A@isoft.com.uy>
X-Deja-AN: 479088314
Content-Transfer-Encoding: 8bit
References: <37414795.ABE6F2A3@nupis.de>
X-Accept-Language: en,ja
Content-Type: text/plain; charset=iso-8859-1
Organization: IdeaSoft
Mime-Version: 1.0
Newsgroups: borland.public.jbuilder.java.swing