home *** CD-ROM | disk | FTP | other *** search
Java Source | 1997-05-08 | 2.3 KB | 87 lines |
- /*
- This simple extension of the java.awt.Frame class
- contains all the elements necessary to act as the
- main window of an application.
- */
-
- import java.awt.*;
- import java.util.*;
-
- public class HashFrame extends Frame {
- void button1_Clicked(Event event) {
- String job = (String)MPList.get("Tessie O'Gritpipe");
- label1.setText( "Tessie O'Gritpipe is the " + job );
- }
-
- Hashtable MPList = new Hashtable();
-
- public HashFrame() {
-
- //{{INIT_CONTROLS
- setLayout(null);
- addNotify();
- resize(insets().left + insets().right + 405,insets().top + insets().bottom + 305);
- button1 = new java.awt.Button("Find Tessie O'Gritpipe");
- button1.reshape(insets().left + 76,insets().top + 228,252,32);
- add(button1);
- label1 = new java.awt.Label("");
- label1.reshape(insets().left + 24,insets().top + 48,370,37);
- add(label1);
- setTitle("A Basic Application");
- //}}
-
- //{{INIT_MENUS
- //}}
- }
-
- public HashFrame(String title) {
- this();
- setTitle(title);
- }
-
- public synchronized void show() {
- // create a list of MPs
- MPList.put("Roger Dog", "Minister of Happiness" );
- MPList.put("Delores McMasters", "Minister of Lies" );
- MPList.put("Tessie O'Gritpipe", "Minister of Weather");
- MPList.put("Fiona Tarradiddle", "Minister of Sympathy");
- MPList.put("Dennis Arktripe", "Minister of Lies");
- MPList.put("Ratford Snivell", "Under-secretary of Folly");
- MPList.put("Andrew Smithers", "Minister of Lies" );
-
-
- move(50, 50);
- super.show();
- }
-
- public boolean handleEvent(Event event) {
- if (event.id == Event.WINDOW_DESTROY) {
- hide(); // hide the Frame
- dispose(); // free the system resources
- System.exit(0); // close the application
- return true;
- }
- if (event.target == button1 && event.id == Event.ACTION_EVENT) {
- button1_Clicked(event);
- return true;
- }
- return super.handleEvent(event);
- }
-
- public boolean action(Event event, Object arg) {
- return super.action(event, arg);
- }
-
- static public void main(String args[]) {
- (new HashFrame()).show();
- }
-
- //{{DECLARE_CONTROLS
- java.awt.Button button1;
- java.awt.Label label1;
- //}}
-
- //{{DECLARE_MENUS
- //}}
- }
-