The output appers as shown in following figure 1124

This preview shows page 206 - 212 out of 521 pages.

We have textbook solutions for you!
The document you are viewing contains questions related to this textbook.
Discovering Computers ©2018: Digital Technology, Data, and Devices
The document you are viewing contains questions related to this textbook.
Chapter 11 / Exercise 44
Discovering Computers ©2018: Digital Technology, Data, and Devices
Sebok/Vermaat
Expert Verified
The output appers as shown in following figure :
We have textbook solutions for you!
The document you are viewing contains questions related to this textbook.
Discovering Computers ©2018: Digital Technology, Data, and Devices
The document you are viewing contains questions related to this textbook.
Chapter 11 / Exercise 44
Discovering Computers ©2018: Digital Technology, Data, and Devices
Sebok/Vermaat
Expert Verified
11.2.4 Radio Button: Radio buttons are a bunch of option boxes in a group. Only one of then can be checked at a time. This is useful if you need to give the user a few options where only one will apply. This is the special case of the Checkbox component of Java AWT package. This is used as a group of checkboxes whos group name is same. Only one Checkbox from a Checkbox Group can be selected at a time. Syntax for creating radio buttons is as follows: CheckboxGroup chkboxgp = new CheckboxGroup (); add (new Checkbox ("chkboxname", chkboxgp, value); ―Value‖ in the second statement can only be true or false.If you mention more than one true valued for checkboxes then your program takes the last true and shows the last check box as checked. Example for Radio Buttons. import java.awt.*; import java.applet.Applet; /*<applet code="Rbutton" width=200 height=100> </applet> */ public class Rbutton extends Applet { public void init() {
CheckboxGroup chkgp = new CheckboxGroup (); add (new Checkbox ("One", chkgp, false)); add (new Checkbox ("Two", chkgp, false)); add (new Checkbox ("Three",chkgp, false)); } } In the above code we are making three check boxes with the label "One", "Two" and "Three". Save the file as Rbutton. Java Compile the file using javac Rbutton.java On successful compilation, execute the file using appletviewer Rbutton.java The output appers as shown in following figure : 11.2.5 Text Area: This is the text container component of Java AWT package. The Text Area contains plain text. TextArea can be declared as follows:
TextArea txtArea_name = new TextArea (); You can make the Text Area editable or not using the setEditable (boolean) method. If you pass the boolean valued argument falsethen the text area will be non-editable otherwise it will be editable. The text area is by default in editable mode. Texts are set in the text area using the setText (string) method of the TextArea class. Example for Text Area:- import java.awt.*; import java.applet.Applet; /*<applet code="TAreaTest" width=200 height=100> </applet> */ public class TAreaTestextends Applet { TextArea disp; public void init() { disp = new TextArea("Code goes here", 10, 30); add (disp); } }
Save the file as TAreaTest. Java Compile the file using javac TAreaTest.java On successful compilation, execute the file using appletviewer TAreaTest.java The output appers as shown in following figure : 11.2.6 Text Field: This is also the text container component of Java AWT package. This component contains single line and limited text information. This is declared as follows: TextField txtfield = new TextField (20);You can fix the number of columns in the text field by specifying the number in the constructor. In the above code we have fixed the number of columns to 20. A displayed label object is known as the Label. Most of the times label is used to demonstrate the significance of the other parts of the GUI. It helps to display the functioning of the next text field. A label is also restricted to a single line of text as a button.
Example for Text Field:-import java.awt.*; import java.applet.Applet;

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture