private void setSliderEnable() { if (movementType.getSelectedItem().equals(STATIONARY_TEXT)) { mySpeedSlider.setEnabled(false); myDurationSlider.setEnabled(false); } else { mySpeedSlider.setEnabled(true); myDurationSlider.setEnabled(true); } myHitPointsSlider.setEnabled(true); }
private void createSliders() { JPanel sliderPanel = new JPanel(); sliderPanel.setLayout(new BoxLayout(sliderPanel, BoxLayout.Y_AXIS)); mySpeedSlider = new SliderObject(MOVEMENT_SPEED_SLIDER_NAME, 0, SLIDER_RANGE); mySpeedSlider.addChangeListener(new SpeedListener()); mySpeedSlider.setEnabled(false); myDurationSlider = new SliderObject(MOVEMENT_DURATION_SLIDER_NAME, 0, SLIDER_RANGE); myDurationSlider.addChangeListener(new DurationListener()); myDurationSlider.setEnabled(false); myHitPointsSlider = new SliderObject(HIT_POINTS_FOR_OBJECT_TEXT, 1, SLIDER_RANGE); myHitPointsSlider.addChangeListener(new DurationListener()); myHitPointsSlider.setEnabled(false); sliderPanel.add(mySpeedSlider); sliderPanel.add(myDurationSlider); sliderPanel.add(myHitPointsSlider); sliderPanel.setPreferredSize(SLIDER_PANEL_SIZE); sliderPanel.setMaximumSize(SLIDER_PANEL_SIZE); homePanel.add(sliderPanel); }