0 Replies Latest reply: May 2, 2009 12:03 PM by user12076936 RSS

    to hide JSpinner with a checbox?

    user12076936
           private SpinnerNumberModel alarmIntervals = new SpinnerNumberModel(DEF_TIME_ALARM, DEF_TIME_ALARM, DEF_TIME_ALARM*QUARTERS_DAY, DEF_TIME_ALARM);
           private JSpinner alarmIntervalSelector;
      private JCheckBox alarmOption;
      
                alarmOption = new JCheckBox(ALARM);
                alarmIntervalSelector = new JSpinner(alarmIntervals);
                alarmIntervalSelector.setVisible(false);
      
                buttons.add(alarmOption);
                alarmOption.addActionListener(this);
                buttons.add(alarmIntervalSelector);
      
      
      
           public void itemStateChanged(ItemEvent selectedItem){
                              if (selectedItem.getSource() == alarmOption){
                          if (selectedItem.getStateChange() == ItemEvent.SELECTED){
                          alarmIntervalSelector.setVisible(true); frame.pack();
                           } else if (selectedItem.getStateChange() == ItemEvent.DESELECTED){
                          alarmIntervalSelector.setVisible(false); // should disable alarm?
                          frame.pack();
                     }
              }
      These are snippets of the code that seem not to work. Basically I'm trying to hide a component (JSpinner) until the checbox is selected, and vice versa. Yet in the implementation clicking on the checkbox does nothing (should display the jspinner).