Results 1 to 3 of 3

Thread: Menu with ButtonGroup

  1. #1
    Join Date
    Aug 2004
    Posts
    203

    Default Menu with ButtonGroup

    Hello,
    I want create menu with a few JCheckBox members and only one selected (like ButtonGroup do)
    How I can do it with TargetableActionCommand (menu have another item, too) ?


    regards

  2. #2
    Join Date
    Aug 2004
    Location
    Melbourne, FL
    Posts
    2,794

    Default

    Snpe,

    Take a look at an example of this in the application.setup license wizard support--the class is SetupLicenseWizardPage. In it, it creates an exclusive command group and generates radio buttons for the accept / do not accept commands. You can apply a siimiliar approach, only generate check boxes instead of radio buttons:

    Code:
        protected JComponent createControl() {
            ...
    
            ToggleCommand acceptCommand = new ToggleCommand("acceptLicenseCommand") {
                protected void onSelection() {
                    SetupLicenseWizardPage.this.setEnabled(true);
                }
            };
    
            ToggleCommand doNotAcceptCommand = new ToggleCommand("doNotAcceptLicenseCommand") {
                protected void onSelection() {
                    SetupLicenseWizardPage.this.setEnabled(false);
                }
            };
            doNotAcceptCommand.setSelected(true);
    
            CommandGroup.createExclusiveCommandGroup(new ToggleCommand[] { acceptCommand, doNotAcceptCommand });
    
            GridBagLayoutBuilder formBuilder = new GridBagLayoutBuilder();
            formBuilder.append(new JScrollPane(licenseTextPane), 1, 1, true, true);
            formBuilder.nextLine();
            // can say createCheckBox instead...
            formBuilder.append(acceptCommand.createRadioButton());
            formBuilder.nextLine();
            formBuilder.append(doNotAcceptCommand.createRadioButton());
            return formBuilder.getPanel();
        }
    Keith
    Keith Donald
    Core Spring Development Team

  3. #3
    Join Date
    Aug 2004
    Posts
    203

    Default

    It work fine.Thanks

Similar Threads

  1. popup menu. escape key, and cancel command
    By lstreepy in forum Swing
    Replies: 3
    Last Post: Sep 13th, 2005, 11:45 AM
  2. ComboBox popup menu behaviour
    By hszetu in forum Swing
    Replies: 0
    Last Post: Aug 30th, 2005, 07:02 PM
  3. Struts menu and acl
    By tkoch in forum Security
    Replies: 1
    Last Post: Aug 23rd, 2005, 06:49 PM
  4. Replies: 3
    Last Post: Aug 10th, 2005, 08:21 AM
  5. Replies: 1
    Last Post: Feb 15th, 2005, 01:05 PM

Posting Permissions

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