// // SimpleFrame class // part of the set of documents known as Java no sugar. // Copyright (c) 1996 Sunil Gupta, sunil@magnetic.demon.co.uk // placed into the public domain by the author // import java.awt.*; import java.applet.*; import OK_Dialog; public class SimpleFrame extends Frame { static final int DIALOG = 1; static final int FRAME = 2; static final int MENUBAR = 3; static final int MENUITEMS = 4; static final int CHECKMENU = 5; Button btn_quit; Button btn_dialog; Label label, lbl_status; MenuBar menubar; Menu menu_file, menu_help, menu_edit, menu_options, menu_cascade, sub_menu; MenuItem close_item; CheckboxMenuItem checked_menu_item; public SimpleFrame( String title, int what) { super(title); this.setLayout( new GridLayout(0,1) ); switch(what) { case FRAME: label = new Label ( "This is a simple frame "+ "But due to paranoid geeks on the net "+ "theres a horrible message at the "+ "bottom of the frame" ); this.add(label); break; case DIALOG: label = new Label("Unfortunately applets dont have direct access to dialogs"); this.add(label); btn_dialog = new Button("Click me for a dialog"); this.add(btn_dialog); break; case MENUBAR: case MENUITEMS: case CHECKMENU: menubar = new MenuBar(); this.setMenuBar(menubar); menu_file = new Menu("File"); menu_edit = new Menu("Edit"); menu_options = new Menu("Options"); menu_help = new Menu("Help"); menu_cascade = new Menu("Cascade"); menubar.add(menu_file); menubar.add(menu_edit); menubar.add(menu_options); menubar.add(menu_cascade); menubar.add(menu_help); menubar.setHelpMenu(menu_help); if (what != MENUBAR) { menu_file.add( new MenuItem("New")); menu_file.add( new MenuItem("Open")); menu_file.add( new MenuItem("-")); menu_file.add( new MenuItem("Print")); menu_file.add( new MenuItem("Print Preview")); menu_file.add( new MenuItem("-")); close_item = new MenuItem("Close"); menu_file.add( close_item); menu_edit.add( new MenuItem("Cut")); menu_edit.add( new MenuItem("Copy")); menu_edit.add( new MenuItem("Paste")); sub_menu = new Menu("Sub menu"); sub_menu.add (new MenuItem("Item 1") ); sub_menu.add (new MenuItem("Item 2") ); sub_menu.add (new MenuItem("Item 3") ); menu_cascade.add(sub_menu); menu_help.add( new MenuItem("About")); if (what == CHECKMENU) { checked_menu_item = new CheckboxMenuItem("HTML mode"); checked_menu_item.setState(true); menu_options.add(checked_menu_item); menu_options.add ( new CheckboxMenuItem("java mode") ); menu_options.add ( new CheckboxMenuItem("C mode") ); menu_options.add ( new CheckboxMenuItem("Delphi mode") ); } } break; } btn_quit = new Button("Quit"); this.add(btn_quit); lbl_status = new Label("status"); this.add(lbl_status); } public SimpleFrame( String title) { this(title, FRAME); } public boolean action(Event event, Object arg) { OK_dialog dialog; CardLayout layout; if ((event.target == btn_quit) || (event.target == close_item)) { this.hide(); this.dispose(); return (true); } else if(event.target == btn_dialog) { dialog = new OK_dialog(this, "this is a dialog", "About"); dialog.show(); return (true); } else if (event.target instanceof MenuItem) { MenuItem the_item; Menu menu; String status; the_item = (MenuItem)(event.target); menu = (Menu) the_item.getParent(); lbl_status.setText( "item " + arg +" in " + menu.getLabel() ); return (true); } return(false); } }
file: /Techref/language/JAVA/nosugar/ui/code/SimpleFrame.java, 3KB, , updated: 1996/10/10 10:10, local time: 2024/11/19 09:38,
18.223.196.123:LOG IN
|
©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions? <A HREF="http://massmind.org/techref/language/JAVA/nosugar/ui/code/SimpleFrame.java"> language JAVA nosugar ui code SimpleFrame</A> |
Did you find what you needed? |
Welcome to massmind.org! |
Welcome to massmind.org! |
.