home *** CD-ROM | disk | FTP | other *** search
Java Source | 1998-12-14 | 3.7 KB | 191 lines |
- import java.awt.*;
-
- import java.applet.*;
-
- public class Checkbox1 extends Applet
- {
-
- void displayButton_Clicked(java.awt.event.[ccc]
- ActionEvent event)
- {
-
- // clear the results area
-
- results.setText("");
-
- // display the gender
-
- Checkbox current = genderGroup.getSelectedCheckbox();
-
- results.append(current.getLabel() + "\r\n");
-
-
- // check each of the sports
-
- if (artCheckbox.getState() == true)
-
- results.append("Art\r\n");
-
- if (psychologyCheckbox.getState() == true)
-
- results.append("Psychology\r\n");
-
- if (historyCheckbox.getState() == true)
-
- results.append("History\r\n");
-
- if (musicCheckbox.getState() == true)
-
- results.append("Music\r\n");
-
- if (scienceCheckbox.getState() == true)
-
- results.append("Science\r\n");
-
- }
-
-
- public void init() {
-
- // Call parents init method.
-
- super.init();
-
-
- // This code is automatically generated by Visual Cafe
-
- // when you add components to the visual environment.
-
- // It instantiates and initializes the components. To
-
- // modify the code, use only code syntax that matches
-
- // what Visual Cafe can generate, or Visual Cafe may
-
- // be unable to back parse your Java file into its
-
- // visual environment.
-
- //{{INIT_CONTROLS
-
- setLayout(null);
-
- resize(442,354);
-
- label1 = new java.awt.Label("Gender:",Label.RIGHT);
-
- label1.setBounds(72,24,84,28);
-
- add(label1);
-
- genderGroup = new CheckboxGroup();
-
- maleButton = new java.awt.Checkbox("Male",genderGroup,
-
- true);
-
- maleButton.setBounds(168,24,58,21);
-
- add(maleButton);
-
- femaleButton = new java.awt.Checkbox("Female",
-
- genderGroup, false);
-
- femaleButton.setBounds(240,24,71,21);
-
- add(femaleButton);
-
- historyCheckbox = new java.awt.Checkbox("History");
-
- historyCheckbox.setBounds(36,96,60,21);
-
- add(historyCheckbox);
-
- psychologyCheckbox = new java.awt.Checkbox("Psychology");
-
- psychologyCheckbox.setBounds(101,96,85,21);
-
- add(psychologyCheckbox);
-
- artCheckbox = new java.awt.Checkbox("Art");
-
- artCheckbox.setBounds(190,96,40,21);
-
- add(artCheckbox);
-
- musicCheckbox = new java.awt.Checkbox("Music");
-
- musicCheckbox.setBounds(238,96,56,21);
-
- add(musicCheckbox);
-
- scienceCheckbox = new java.awt.Checkbox("Science");
-
- scienceCheckbox.setBounds(298,96,93,21);
-
- add(scienceCheckbox);
-
- displayButton = new java.awt.Button("Display");
-
- displayButton.setBounds(48,204,100,33);
-
- add(displayButton);
-
- results = new java.awt.TextArea();
-
- results.setBounds(180,144,246,198);
-
- add(results);
-
- Action lAction = new Action();
-
- displayButton.addActionListener(lAction);
-
- }
-
-
- java.awt.Label label1;
-
- java.awt.Checkbox maleButton;
-
- CheckboxGroup genderGroup;
-
- java.awt.Checkbox femaleButton;
-
- java.awt.Label label2;
-
- java.awt.Checkbox historyCheckbox;
-
- java.awt.Checkbox psychologyCheckbox;
-
- java.awt.Checkbox artCheckbox;
-
- java.awt.Checkbox musicCheckbox;
-
- java.awt.Checkbox scienceCheckbox;
-
- java.awt.Button displayButton;
-
- java.awt.TextArea results;
-
-
-
- class Action implements java.awt.event.ActionListener {
-
- public void actionPerformed(java.awt.event.ActionEvent
-
- event) {
-
- Object object = event.getSource();
-
- if (object == displayButton)
-
- displayButton_Clicked(event);
-
- }
-
- }
-
- }
-