Total members 11829 |It is currently Thu May 28, 2020 10:22 pm Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





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:




Author:
Newbie
User avatar Posts: 19
Have thanks: 0 time

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());
        }
      }
    });
 


_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time
Post new topic Reply to topic  [ 2 posts ] 

  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






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com