🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: es.comp.lenguajes.java
Article #27629

Re: "_ O X " how can I handle the event "close window"?

#27629
From: Bernardo Martin Gonzalez Rodrigu...
Date: Thu, 13 Aug 1998 00:00
39 lines
1828 bytes
joaquin (jpenass@nexo.es) wrote:
> "_ O X " how can I handle the event "close window"?

> I have a frame, and when a push "X" button the frame don't be closed .
> could anybody help me?

> Please, write me to jpenass@nexo.es

Easy...

You should implement the WindowListener interface inside your frame.
This interface contains 6 abstract methods. The one you are interested
in is the WindowClosing method.

Just redefine it with something like

 public windowClosing (WindowEvent e)
 {
  System.exit (1) // if you wanna exit your application
  }

  Then, you need your frame to capture the WindowClosing event. You
  only need to include the following code in your Frame constructor:

  addWindowListener (this)...

And that is everything you need

Cheers...

Caution:
This example works only for JDK 1.1.x, not for the deprecated 1.0 event system


--
MARTIN dende la ROCA              |  martinc@pinon.ccu.uniovi.es
                                  | 
...solo queden 70 conceyos        | www.uniovi.es/~oviedo3/martin
     ASTURIANU LLINGUA OFICIAL!   |
Technical Details
Message-ID: <6qui6p$u0$1@sci.cpd.uniovi.es>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <01bdc54b$ef53af60$0100007f@joaquinp>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 1116f3,24eda8fc9d6bbc34
X-Google-Attributes: gid1116f3,public
From: martinc@pinon.ccu.uniovi.es (Bernardo Martin Gonzalez Rodriguez)
Subject: Re: "_ O X " how can I handle the event "close window"?
Date: 1998/08/13
Message-ID: <6qui6p$u0$1@sci.cpd.uniovi.es>
X-Deja-AN: 380713559
Content-Transfer-Encoding: 8bit
References: <01bdc54b$ef53af60$0100007f@joaquinp>
Content-Type: text/plain; charset=iso-8859-1
X-Complaints-To: abuse@si.uniovi.es
X-Trace: sci.cpd.uniovi.es 903007257 960 156.35.31.1 (13 Aug 1998 11:20:57 GMT)
Organization: Universidad de Oviedo
Mime-Version: 1.0
NNTP-Posting-Date: 13 Aug 1998 11:20:57 GMT
Newsgroups: es.comp.lenguajes.java