Switch to full style
Java2 codes,problems ,discussions and solutions are here
Post a reply

selection of checkbox in buttongroup in netbeans

Thu Jul 30, 2009 4:46 pm

Hi everybody

I have created a set of checkbox that i set the property "buttongroup" the same for all (i created a buttongroup) .I work with netbeans 6.5.1 so i used the palette to make this.
I want to get the string of the selected checkbox .
the problem that i cant't access to initcomponents () the method where the components are instancied.
If i used :
Code:
buttonGroup1.getSelection().getClass().getName()

I get errors

How i can get the selected item.
Please i need a help :beg: :beg: :beg:



Re: selection of checkbox in buttongroup in netbeans

Fri Jul 31, 2009 1:03 pm

you can use :
Code:

buttonGroup
.getSelection().getSelectedObjects()
 


or another way of thinking is :
Code:

orderButton
.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent ae) {
        String entree = buttonGroup.getSelection().getActionCommand();
        System.out.println(entree + " sandwich");
        Component[] components = condimentsPanel.getComponents();
        for (Component c : components) {
          JCheckBox cb = (JCheckBox) c;
          if (cb.isSelected())
            System.out.println("With " + cb.getText());
        }
      }
    });
 


Post a reply
  Related Posts  to : selection of checkbox in buttongroup in netbeans
 Check-Uncheck checkbox button using JQuery     -  
 applet in netbeans     -  
 information about netbeans IDE     -  
 creating database in netbeans     -  
 i am using NetBeans 7.0, HELP NEEDED - URGENT     -  
 Data Base problem with Netbeans IDE     -  
 chat system project in java using netbeans     -  
 selection sort     -  
 C++ Selection Sort     -  
 Help with selection sort for strings?     -  

Topic Tags

Java Swing