Results 1 to 3 of 3
  1. #1
    orionorion is offline Member
    Join Date
    Feb 2011
    Posts
    3
    Rep Power
    0

    Default Checkbox hellllppp

    import java.applet.Applet;
    import java.awt.*;
    import java.awt.event.*;

    public class wala extends Applet implements ActionListener
    {
    CheckboxGroup optButtonGroup;
    Checkbox optButton1;
    Checkbox optButton2;
    Checkbox optButton3;

    TextField txtText1;
    TextField txtText2;
    Button s;

    public void init(){
    optButtonGroup = new CheckboxGroup();
    optButton1=new Checkbox("Opt1", false, optButtonGroup);
    add(optButton1);


    optButton2=new Checkbox("Opt2", false, optButtonGroup);
    add(optButton2);


    optButton3=new Checkbox("Opt3", false, optButtonGroup);
    add(optButton3);


    txtText1 = new TextField(20);
    add(txtText1);

    s=new Button("ENTER");
    add(s);
    s.addActionListener(this);

    }

    public void actionPerformed(ActionEvent e)
    {



    }
    }

    i don't know the syntax ... . .when i click the button. example when none of the optionbutton was checked a dialog box will pop-out and will said the . .You have not check one of the optionbutton

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    4,038
    Rep Power
    10

    Default

    When posting code, make sure you use the code tags. Look at any other post for plenty of examples of how to do that.

    But what exactly is your question?
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    eRaaaa is offline Senior Member
    Join Date
    Oct 2010
    Location
    Germany
    Posts
    787
    Rep Power
    6

    Default

    CheckboxGroup (Java Platform SE 6)
    --> optButtonGroup.getSelectedCheckbox() will return null if no checkbox is selected.
    Write an if-statement and check the return value of that method --> show your dialog if it is null :)

Similar Threads

  1. Replies: 3
    Last Post: 07-27-2010, 10:52 AM
  2. checkbox question
    By HellRider in forum AWT / Swing
    Replies: 1
    Last Post: 02-09-2010, 04:35 PM
  3. CheckBox
    By boss in forum NetBeans
    Replies: 3
    Last Post: 01-17-2010, 05:51 AM
  4. CheckBox in JTable
    By nikosa in forum AWT / Swing
    Replies: 1
    Last Post: 08-05-2009, 06:01 AM
  5. checkbox
    By Alan in forum AWT / Swing
    Replies: 3
    Last Post: 05-18-2007, 11:10 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •