Java The Complete Reference, Seventh Edition
708 Part II: The Java Library The following program creates four check boxes. The initial state of the first box is checked. The ...
Chapter 24: Using AWT Controls, Layout Managers, and Menus 709 CheckboxGroup It is possible to create a set of mutually exclusiv ...
CheckboxGroup cbg; public void init() { cbg = new CheckboxGroup(); winXP = new Checkbox("Windows XP", cbg, true); winVista = new ...
Choice Controls TheChoiceclass is used to create apop-up listof items from which the user may choose. Thus, aChoicecontrol is a ...
712 Part II: The Java Library import java.applet.*; /* <applet code="ChoiceDemo" width=300 height=180> </applet> */ ...
Using Lists TheListclass provides a compact, multiple-choice, scrolling selection list. Unlike the Choiceobject, which shows onl ...
714 Part II: The Java Library returns the index of the item. The first item is at index 0. If more than one item is selected, or ...
Chapter 24: Using AWT Controls, Layout Managers, and Menus 715 String msg = ""; public void init() { os = new List(4, true); bro ...
716 Part II: The Java Library Managing Scroll Bars Scroll barsare used to select continuous values between a specified minimum a ...
Chapter 24: Using AWT Controls, Layout Managers, and Menus 717 Here,newValuespecifies the new value for the scroll bar. When you ...
718 Part II: The Java Library Scrollbar vertSB, horzSB; public void init() { int width = Integer.parseInt(getParameter("width")) ...
Using a TextField TheTextFieldclass implements a single-line text-entry area, usually called anedit control. Text fields allow t ...
720 Part II: The Java Library You can control whether the contents of a text field may be modified by the user by callingsetEdit ...
add(name); add(passp); add(pass); // register to receive action events name.addActionListener(this); pass.addActionListener(this ...
Here,numLinesspecifies the height, in lines, of the text area, andnumCharsspecifies its width, in characters. Initial text can b ...
Chapter 24: Using AWT Controls, Layout Managers, and Menus 723 Here is sample output from theTextAreaDemoapplet: Understanding L ...
724 Part II: The Java Library will honor these requests if at all possible, while maintaining the integrity of the layout policy ...
public void init() { // set left-aligned flow layout setLayout(new FlowLayout(FlowLayout.LEFT)); winXP = new Checkbox("Windows X ...
726 Part II: The Java Library south, east, and west. The middle area is called the center. Here are the constructors defined byB ...
Chapter 24: Using AWT Controls, Layout Managers, and Menus 727 Sample output from theBorderLayoutDemoapplet is shown here: Using ...
«
33
34
35
36
37
38
39
40
41
42
»
Free download pdf