[5413] in java-interest

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

Why the Dialog box comes out twice ?

daemon@ATHENA.MIT.EDU (mark@hactl.com.hk)
Thu Feb 8 04:42:04 1996

From: mark@hactl.com.hk
Date: Thu, 8 Feb 1996 15:27:31 +0800
To: java-interest@java.sun.com
Cc: mark@hactl.com.hk

     Hi guys,
     
     I  written a experimental program for my room booking application. The 
     only function of the source code below is when mouse is clicked in the 
     frame it will pop up a dialogbox. The problem I meet is each time when 
     I click the mouse the Dialog box comes out twice. Could somebody 
     please tell me what is wrong. I would appreciate your advice.
     
     Best regards,
     
     Mark
     
     
     ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     
     import java.awt.*;
     import java.io.*;
     import java.util.*;
     
     public class CRBS1 extends Frame
     {
             static final int H_SIZE = 400;
             static final int V_SIZE = 360;
     
             Book book=null;
     
             public CRBS1()
             {
       
               super("Room Booking System");
               setFont(new Font("TimesRoman", Font.PLAIN, 12));
               setBackground(Color.white);
               setForeground(Color.black);
               setLayout(new BorderLayout());
               pack();
               resize(H_SIZE, V_SIZE);
               show();
             }
     
        public boolean handleEvent(Event evt)
        {
             switch(evt.id)
               {
                     case Event.WINDOW_DESTROY:
                     {
                             System.exit(0);
                             return true;
                     }
                     case Event.MOUSE_DOWN:
                     {
                       BookDialog DB = new BookDialog(this);
                       return true;
                      }
     
                     default:
                        return false;
          }
        }
     
             public static void main(String args[])
             {
                     new CRBS1();
             }
     }
     
     class BookDialog extends Dialog
     {
         static int H_SIZE = 300;
         static int V_SIZE = 200;
     
         public BookDialog(Frame parent)
         {
           super(parent,"Book a Room",false);
           setBackground(Color.gray);
           setLayout(new BorderLayout());
           Panel p = new Panel();
           p.add(new Button("OK"));
           p.add(new Button("CANCEL"));
           add("South",p);
           resize(H_SIZE, V_SIZE);
           show();
         }
     
        public boolean action(Event evt, Object arg)
        {
           if(arg.equals("OK"))
           {
              dispose();
              return true;
           }
           return false;
         }
     }
     
-
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