CATEGORII DOCUMENTE |
Asp | Autocad | C | Dot net | Excel | Fox pro | Html | Java |
Linux | Mathcad | Photoshop | Php | Sql | Visual studio | Windows | Xml |
A check box provides a way to make a single on-off choice; it consists of a tiny box and a label. The box typically holds a little 'x' (or some other indication that it is set) or is empty depending on whether that item was selected.
You'll normally create a Checkbox using a constructor that takes the label as an argument. You can get and set the state, and also get and set the label if you want to read or change it after the Checkbox has been created. Note that the capitalization of Checkbox is inconsistent with the other controls, which could catch you by surprise since you might expect it to be "CheckBox."
Whenever a Checkbox is set or cleared an event occurs, which you can capture the same way you do a button. The following example uses a TextArea to enumerate all the check boxes that have been checked:
//: CheckBox1.java
// Using check boxes
import java.awt.*;
import java.applet.*;
public class CheckBox1 extends Applet
public boolean action (Event evt, Object arg)
void trace(String b, boolean state)
} ///:~
The trace( ) method sends the name of the selected Checkbox and its current state to the TextArea using appendText( ) so you'll see a cumulative list of the checkboxes that were selected and what their state is.
Politica de confidentialitate | Termeni si conditii de utilizare |
Vizualizari: 493
Importanta:
Termeni si conditii de utilizare | Contact
© SCRIGROUP 2024 . All rights reserved