home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD 12 / 12_pcplus_supercd.iso / Pcplus / JAVA / HASHFRAME / HASHFRAME.JAVA
Encoding:
Java Source  |  1997-05-08  |  2.3 KB  |  87 lines

  1. /*
  2.     This simple extension of the java.awt.Frame class
  3.     contains all the elements necessary to act as the
  4.     main window of an application.
  5.  */
  6.  
  7. import java.awt.*;
  8. import java.util.*;
  9.  
  10. public class HashFrame extends Frame {
  11.     void button1_Clicked(Event event) {
  12.         String job = (String)MPList.get("Tessie O'Gritpipe");
  13.         label1.setText( "Tessie O'Gritpipe is the " + job );
  14.     }
  15.  
  16.     Hashtable MPList = new Hashtable();
  17.  
  18.     public HashFrame() {
  19.  
  20.         //{{INIT_CONTROLS
  21.         setLayout(null);
  22.         addNotify();
  23.         resize(insets().left + insets().right + 405,insets().top + insets().bottom + 305);
  24.         button1 = new java.awt.Button("Find Tessie O'Gritpipe");
  25.         button1.reshape(insets().left + 76,insets().top + 228,252,32);
  26.         add(button1);
  27.         label1 = new java.awt.Label("");
  28.         label1.reshape(insets().left + 24,insets().top + 48,370,37);
  29.         add(label1);
  30.         setTitle("A Basic Application");
  31.         //}}
  32.  
  33.         //{{INIT_MENUS
  34.         //}}
  35.     }
  36.  
  37.     public HashFrame(String title) {
  38.         this();
  39.         setTitle(title);
  40.     }
  41.  
  42.     public synchronized void show() {
  43.                 // create a list of MPs
  44.         MPList.put("Roger Dog", "Minister of Happiness" );
  45.         MPList.put("Delores McMasters", "Minister of Lies" );        
  46.         MPList.put("Tessie O'Gritpipe", "Minister of Weather");
  47.         MPList.put("Fiona Tarradiddle", "Minister of Sympathy");
  48.         MPList.put("Dennis Arktripe", "Minister of Lies");
  49.         MPList.put("Ratford Snivell", "Under-secretary of Folly");
  50.         MPList.put("Andrew Smithers", "Minister of Lies" );                
  51.  
  52.         
  53.         move(50, 50);
  54.         super.show();
  55.     }
  56.  
  57.     public boolean handleEvent(Event event) {
  58.         if (event.id == Event.WINDOW_DESTROY) {
  59.             hide();         // hide the Frame
  60.             dispose();      // free the system resources
  61.             System.exit(0); // close the application
  62.             return true;
  63.         }
  64.         if (event.target == button1 && event.id == Event.ACTION_EVENT) {
  65.             button1_Clicked(event);
  66.             return true;
  67.         }
  68.         return super.handleEvent(event);
  69.     }
  70.  
  71.     public boolean action(Event event, Object arg) {
  72.         return super.action(event, arg);
  73.     }
  74.  
  75.     static public void main(String args[]) {
  76.         (new HashFrame()).show();
  77.     }
  78.  
  79.     //{{DECLARE_CONTROLS
  80.     java.awt.Button button1;
  81.     java.awt.Label label1;
  82.     //}}
  83.  
  84.     //{{DECLARE_MENUS
  85.     //}}
  86. }
  87.