[4645] in java-interest

home help back first fref pref prev next nref lref last post

Problem with handling events (killing windows in a menubar of a frame & WINDOW_DESTROY)

daemon@ATHENA.MIT.EDU (Sian Tan)
Wed Jan 10 05:46:26 1996

Date: Wed, 10 Jan 1996 01:19:51 -0800
From: Sian Tan <tan@cdr.stanford.edu>
CC: java-interest@java.sun.com, tan@cdr.stanford.edu

Hi.

I'm trying to spruce up my user interface to have menuitem interaction. 
I'm using the method below to take care of mouse actions on the menubar 
of the frame. This works fine by itself. It kills the window. However, 
when I try to add the second code segment below into the same class, the 
window closes if I click the "close window" button on the window, but my 
menu items fail to function. What am I doing wrong here?

And Sami Shaio, if and when you read this, my congratulations for 
producing a wonderful book. "Hooked on Java" really does the job. 

Reply by e-mail to: tan@cdr.stanford.edu is requested.

*************** 1st code segment ***************
 public boolean action(Event evt, Object obj) {
        if (evt.target instanceof MenuItem) {
            String label = (String)obj;
            if (label.equals(QUIT)){
                this.dispose();
                System.exit(0); 
            }

	etc. -------- etc.

*************** 2nd code segment ***************
  public boolean handleEvent(Event evt) {
        switch(evt.id){
            case Event.WINDOW_DESTROY:{
                this.dispose();
                System.exit(0);
                return true;
            }
            default:
                return false;
        }
  }
-- 

**************************
Sian Tan
Center for Design Research
560 Panama Street
Stanford, CA 94305
Tel: 1-415-725 0161
Fax: 1-415-725 8475
**************************
-
This message was sent to the java-interest mailing list
Info: send 'help' to java-interest-request@java.sun.com

home help back first fref pref prev next nref lref last post