🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Preventing close of JInternalFrame

#10632
From: Jim Stoll
Date: Mon, 23 Aug 1999 00:00
100 lines
4202 bytes
Alex,
I'm catching the attempted close w/ the VetoableChangeListener, and providing
an opportunity for the programmer to stop the close w/ another method, as
follows:

public class MDISheet extends JInternalFrame implements
VetoableChangeListener{
 ...
//VetoableChangeListener Implementation
 public void vetoableChange(PropertyChangeEvent evt) throws
java.beans.PropertyVetoException {
    boolean continueClose = true;

    //if sheet is trying to close (VetoableChangeListener receives other
types of notifications, as well...)
    if (evt.getPropertyName().equals(IS_CLOSED_PROPERTY) &&
(Boolean)evt.getNewValue() == Boolean.TRUE) {
      //allow stopping of close process via sheetClosing method
      continueClose = sheetClosing();
      if (continueClose) {
        //do whatever needs to be done before the close continues
      }
      else
      //sheet close was stopped in sheetClosing method, throw
PropertyVetoException to be caught by
      // object that initiated the close of the sheet
        throw new PropertyVetoException("", evt);
    }
  }

//method that users of MDISheet should code to allow/disallow closing of
JInternalFrame
public boolean sheetClosing() {
    //return true to allow sheet to continue closing
    //return false to prevent sheet from closing
    return true;
  }
}

Not sure what's up w/ the internalFrameClosing method, but this alternate
method seems to work alright, if not quite as elegantly as the 'real' method
should...

I had a similar problem w/ the openFrame method of the DefaultDesktopManager
- (_it's_ at least documented that the event doesn't typically trigger...
:-), so I had to make a call from the JInternalFrame to the DesktopManager of
the parent frame's DesktopPane to permit generic handling of opening of a
JInternalFrame.  These are the only real glitches I've come across thus far,
though - overall, I like the JInternalFrame/JFrame/DesktopManager deal. :-)

Jim



"Alex Tavera V." wrote:

> How is your implementation of the VetoableChangeListener?
>
> I have the same problem with the Internal clossing event.
>
> Thanks.
>
> Alex
>
> Jim Stoll <jestoll@crtnet.com> wrote in message
> news:37BC1CBA.312E939F@crtnet.com...
> > It's happening in both 1.1.6 and 1.2.2 - kinda screwy.  At this point,
> > I've got it all setup to use a VetoableChangeListener and it's working
> > alright, so while I'm a little bummed, I'm willing to roll w/ it.
> >
> > Thanks for the info,
> >
> > Jim
> >
> > Michael H�rtig wrote:
> >
> > > Hi,
> > >
> > > Which JDK do you use??
> > >
> > > I think until 1.2.1 it is a official bug (can't remebmber the Bug-ID)
> > > But I got a eMail from Sun and the say in 1.2.2 it is ok. But I don't
> > > tested it.
> > >
> > > Michael
> > > --
> > >            ////
> > >           (o o)
> > > +-----ooO--(_)--Ooo---------------------------------------+
> > > |                                                         |
> > > | Michael H�rtig                 Neumann & Partner        |
> > > |                                Informationssysteme GmbH |
> > > | Softwareentwicklung            An der Hohen Stra�e 1    |
> > > |                                08393 Meerane            |
> > > |                                                         |
> > > +------------Oooo-----------------------------------------+
> > >         oooO (  )
> > >         (  )  (_)
> > >          (_)
> >
Technical Details
Message-ID: <37C17A2E.DCC6DC06@crtnet.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <37BB2406.ABEB620D@crtnet.com> <7pf8j6$30v1@forums.borland.com> <37BB2C0A.CB9B343@crtnet.com> <37BC00FC.831632B5@nupis.de> <37BC1CBA.312E939F@crtnet.com> <7prnld$g3o19@forums.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: 111d45,6a1846c8084a630a
X-Google-Attributes: gid111d45,public
From: Jim Stoll <jestoll@crtnet.com>
Subject: Re: Preventing close of JInternalFrame
Date: 1999/08/23
Message-ID: <37C17A2E.DCC6DC06@crtnet.com>
X-Deja-AN: 516223593
Content-Transfer-Encoding: 8bit
References: <37BB2406.ABEB620D@crtnet.com> <7pf8j6$30v1@forums.borland.com> <37BB2C0A.CB9B343@crtnet.com> <37BC00FC.831632B5@nupis.de> <37BC1CBA.312E939F@crtnet.com> <7prnld$g3o19@forums.borland.com>
X-Accept-Language: en
Content-Type: text/plain; charset=iso-8859-1
Organization: Another Netscape Collabra Server User
Mime-Version: 1.0
Newsgroups: borland.public.jbuilder.java.swing