// // WidgetDemo 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.*; public class WidgetDemo extends Applet { //******************************************************************* // globals //******************************************************************* static final String BUTTON = "BUTTON"; static final String CHECKBOX = "CHECKBOX"; static final String CHOICE = "CHOICE"; static final String LABEL = "LABEL"; static final String LIST = "LIST"; static final String SCROLLBAR = "SCROLLBAR"; static final String TEXTAREA = "TEXTAREA"; static final String TEXTFIELD = "TEXTFIELD"; //******************************************************************* // applet methods //******************************************************************* public void init() { String style; style = getParameter("STYLE"); if (style == null) System.exit(1); else { this.setLayout( new FlowLayout()); if (style.equals(BUTTON)) { this.add( new Button("A button")); } else if (style.equals(CHECKBOX)) { CheckboxGroup group; Checkbox[] boxes; group = new CheckboxGroup(); boxes = new Checkbox[3]; boxes[0] = new Checkbox("First item", group, false); boxes[1] = new Checkbox("Second item", group, true); boxes[2] = new Checkbox("Third item", group, false); this.add(boxes[0]); this.add(boxes[1]); this.add(boxes[2]); this.add(new Checkbox("outside group", null, false)); } else if (style.equals(CHOICE)) { Choice thing; thing = new Choice(); thing.addItem("First Choice"); thing.addItem("Second Choice"); thing.addItem("Third Choice"); this.add(thing); } else if (style.equals(LIST)) { List list; list = new List(4, true); list.addItem("Machine Code"); list.addItem("Assembler"); list.addItem("Basic"); list.addItem("Visual Basic"); list.addItem("C"); list.addItem("C++"); list.addItem("Java"); list.addItem("* Delphi *"); this.add(list); } else if (style.equals(LABEL)) { this.add( new Label("A label")); } else if (style.equals(SCROLLBAR)) { this.add ( new Scrollbar(Scrollbar.VERTICAL)); this.add ( new Scrollbar(Scrollbar.HORIZONTAL)); } else if (style.equals(TEXTAREA)) { this.add( new TextArea("This is a text area",5,30)); } else if (style.equals(TEXTFIELD)) { this.add( new TextField("This is a text field",30)); } } } }
file: /Techref/language/java/nosugar/ui/code/WidgetDemo.java, 2KB, , updated: 1996/10/10 10:10, local time: 2024/11/19 08:33,
18.219.26.117: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/WidgetDemo.java"> language java nosugar ui code WidgetDemo</A> |
Did you find what you needed? |
Welcome to massmind.org! |
Welcome to massmind.org! |
.