Package javax.swing.event

Examples of javax.swing.event.ChangeListener


        priceSpinnerModel.setNullable(ev.getNewValue() == null);
        priceSpinnerModel.setValue((Float)ev.getNewValue());
      }
    };
    controller.addPropertyChangeListener(FurnitureController.Property.PRICE, priceChangeListener);
    priceSpinnerModel.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent ev) {
          controller.removePropertyChangeListener(FurnitureController.Property.PRICE, priceChangeListener);
          Object value = priceSpinnerModel.getValue();
          controller.setPrice(value != null
              ? new BigDecimal((Float)value).setScale(2, BigDecimal.ROUND_HALF_UP)
              : (BigDecimal)value);
          controller.addPropertyChangeListener(FurnitureController.Property.PRICE, priceChangeListener);
        }
      });

    // Create VAT % label and its spinner bound to VALUE_ADDED_TAX_PERCENTAGE controller property
    this.valueAddedTaxPercentageLabel = new JLabel(SwingTools.getLocalizedLabelText(preferences,
        FurniturePanel.class, "valueAddedTaxPercentageLabel.text"));
    final NullableSpinner.NullableSpinnerNumberModel valueAddedTaxPercentageSpinnerModel =
        new NullableSpinner.NullableSpinnerNumberModel(0, 0, 100f, 0.1f);
    this.valueAddedTaxPercentageSpinner = new AutoCommitSpinner(valueAddedTaxPercentageSpinnerModel);
    valueAddedTaxPercentageSpinnerModel.setNullable(controller.getValueAddedTaxPercentage() == null);
    valueAddedTaxPercentageSpinnerModel.setValue(controller.getValueAddedTaxPercentage() == null
        ? null
        : controller.getValueAddedTaxPercentage().floatValue() * 100);
    final PropertyChangeListener valueAddedTaxPercentageChangeListener = new PropertyChangeListener() {
      public void propertyChange(PropertyChangeEvent ev) {
        valueAddedTaxPercentageSpinnerModel.setNullable(ev.getNewValue() == null);
        valueAddedTaxPercentageSpinnerModel.setValue(ev.getNewValue() == null
            ? null
            : ((Float)ev.getNewValue()) * 100);
      }
    };
    controller.addPropertyChangeListener(FurnitureController.Property.VALUE_ADDED_TAX_PERCENTAGE, valueAddedTaxPercentageChangeListener);
    valueAddedTaxPercentageSpinnerModel.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent ev) {
          controller.removePropertyChangeListener(FurnitureController.Property.VALUE_ADDED_TAX_PERCENTAGE, valueAddedTaxPercentageChangeListener);
          Object value = valueAddedTaxPercentageSpinnerModel.getValue();
          controller.setValueAddedTaxPercentage(value != null
              ? new BigDecimal((Float)value / 100).setScale(3, BigDecimal.ROUND_HALF_UP)
              : (BigDecimal)value);
          controller.addPropertyChangeListener(FurnitureController.Property.VALUE_ADDED_TAX_PERCENTAGE, valueAddedTaxPercentageChangeListener);
        }
      });
   
    // Create width label and its spinner bound to WIDTH controller property
    this.widthLabel = new JLabel(SwingTools.getLocalizedLabelText(preferences,
        FurniturePanel.class, "widthLabel.text", unitName));
    final float minimumLength = preferences.getLengthUnit().getMinimumLength();
    final NullableSpinner.NullableSpinnerLengthModel widthSpinnerModel =
        new NullableSpinner.NullableSpinnerLengthModel(preferences, minimumLength, 100000f);
    this.widthSpinner = new AutoCommitSpinner(widthSpinnerModel);
    final PropertyChangeListener widthChangeListener = new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent ev) {
          Float width = controller.getWidth();
          widthSpinnerModel.setNullable(width == null);
          widthSpinnerModel.setLength(width);
          if (width != null) {
            widthSpinnerModel.setMinimum(Math.min(width, minimumLength));
          }
        }
      };
    widthChangeListener.propertyChange(null);
    controller.addPropertyChangeListener(FurnitureController.Property.WIDTH, widthChangeListener);
    widthSpinnerModel.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent ev) {
          controller.removePropertyChangeListener(FurnitureController.Property.WIDTH, widthChangeListener);
          controller.setWidth(widthSpinnerModel.getLength());
          if (!controller.isProportional()) {
            resetIcon(false);
          }
          controller.addPropertyChangeListener(FurnitureController.Property.WIDTH, widthChangeListener);
        }
      });
   
    // Create depth label and its spinner bound to DEPTH controller property
    this.depthLabel = new JLabel(SwingTools.getLocalizedLabelText(preferences,
        FurniturePanel.class, "depthLabel.text", unitName));
    final NullableSpinner.NullableSpinnerLengthModel depthSpinnerModel =
        new NullableSpinner.NullableSpinnerLengthModel(preferences, minimumLength, 100000f);
    this.depthSpinner = new NullableSpinner(depthSpinnerModel);
    final PropertyChangeListener depthChangeListener = new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent ev) {
          Float depth = controller.getDepth();
          depthSpinnerModel.setNullable(depth == null);
          depthSpinnerModel.setLength(depth);
          if (depth != null) {
            depthSpinnerModel.setMinimum(Math.min(depth, minimumLength));
          }
        }
      };
    depthChangeListener.propertyChange(null);
    controller.addPropertyChangeListener(FurnitureController.Property.DEPTH, depthChangeListener);
    depthSpinnerModel.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent ev) {
          controller.removePropertyChangeListener(FurnitureController.Property.DEPTH, depthChangeListener);
          controller.setDepth(depthSpinnerModel.getLength());
          if (!controller.isProportional()) {
            resetIcon(false);
          }
          controller.addPropertyChangeListener(FurnitureController.Property.DEPTH, depthChangeListener);
        }
      });
   
    // Create height label and its spinner bound to HEIGHT controller property
    this.heightLabel = new JLabel(SwingTools.getLocalizedLabelText(preferences,
        FurniturePanel.class, "heightLabel.text", unitName));
    final NullableSpinner.NullableSpinnerLengthModel heightSpinnerModel =
        new NullableSpinner.NullableSpinnerLengthModel(preferences, minimumLength, 100000f);
    this.heightSpinner = new NullableSpinner(heightSpinnerModel);
    final PropertyChangeListener heightChangeListener = new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent ev) {
          Float height = controller.getHeight();
          heightSpinnerModel.setNullable(height == null);
          heightSpinnerModel.setLength(height);
          if (height != null) {
            heightSpinnerModel.setMinimum(Math.min(height, minimumLength));
          }
        }
      };
    heightChangeListener.propertyChange(null);
    controller.addPropertyChangeListener(FurnitureController.Property.HEIGHT, heightChangeListener);
    heightSpinnerModel.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent ev) {
          controller.removePropertyChangeListener(FurnitureController.Property.HEIGHT, heightChangeListener);
          controller.setHeight(heightSpinnerModel.getLength());
          if (!controller.isProportional()) {
            resetIcon(false);
          }
          controller.addPropertyChangeListener(FurnitureController.Property.HEIGHT, heightChangeListener);
        }
      });
   
    this.keepProportionsCheckBox = new JCheckBox(SwingTools.getLocalizedLabelText(preferences,
        FurniturePanel.class, "keepProportionsCheckBox.text"), controller.isProportional());
    this.keepProportionsCheckBox.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent ev) {
          controller.setProportional(keepProportionsCheckBox.isSelected());
        }
      });
    controller.addPropertyChangeListener(FurnitureController.Property.PROPORTIONAL,
        new PropertyChangeListener() {
          public void propertyChange(PropertyChangeEvent ev) {
            // If proportional property changes update keep proportions check box
            keepProportionsCheckBox.setSelected(controller.isProportional());
          }
        });
   
    // Create elevation label and its spinner bound to ELEVATION controller property
    this.elevationLabel = new JLabel(SwingTools.getLocalizedLabelText(preferences,
        FurniturePanel.class, "elevationLabel.text", unitName));
    final NullableSpinner.NullableSpinnerLengthModel elevationSpinnerModel =
      new NullableSpinner.NullableSpinnerLengthModel(preferences, 0f, 1000f);
    this.elevationSpinner = new NullableSpinner(elevationSpinnerModel);
    elevationSpinnerModel.setNullable(controller.getElevation() == null);
    elevationSpinnerModel.setLength(controller.getElevation());
    final PropertyChangeListener elevationChangeListener = new PropertyChangeListener() {
      public void propertyChange(PropertyChangeEvent ev) {
        elevationSpinnerModel.setNullable(ev.getNewValue() == null);
        elevationSpinnerModel.setLength((Float)ev.getNewValue());
      }
    };
    controller.addPropertyChangeListener(FurnitureController.Property.ELEVATION,
        elevationChangeListener);
    elevationSpinnerModel.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent ev) {
          controller.removePropertyChangeListener(FurnitureController.Property.ELEVATION,
              elevationChangeListener);
          controller.setElevation(elevationSpinnerModel.getLength());
          controller.addPropertyChangeListener(FurnitureController.Property.ELEVATION,
              elevationChangeListener);
        }
      });

    // Create movable check box bound to MOVABLE controller property
    this.movableCheckBox = new NullableCheckBox(SwingTools.getLocalizedLabelText(preferences,
        FurniturePanel.class, "movableCheckBox.text"));
    this.movableCheckBox.setNullable(controller.getMovable() == null);
    this.movableCheckBox.setValue(controller.getMovable());
    final PropertyChangeListener movableChangeListener = new PropertyChangeListener() {
      public void propertyChange(PropertyChangeEvent ev) {
        movableCheckBox.setNullable(ev.getNewValue() == null);
        movableCheckBox.setValue((Boolean)ev.getNewValue());
      }
    };
    controller.addPropertyChangeListener(FurnitureController.Property.MOVABLE, movableChangeListener);
    this.movableCheckBox.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent ev) {
          controller.removePropertyChangeListener(FurnitureController.Property.MOVABLE, movableChangeListener);
          controller.setMovable(movableCheckBox.getValue());
          controller.addPropertyChangeListener(FurnitureController.Property.MOVABLE, movableChangeListener);
        }
      });
   
    // Create doorOrWindow check box bound to DOOR_OR_WINDOW controller property
    this.doorOrWindowCheckBox = new NullableCheckBox(SwingTools.getLocalizedLabelText(preferences,
        FurniturePanel.class, "doorOrWindowCheckBox.text"));
    this.doorOrWindowCheckBox.setNullable(controller.getDoorOrWindow() == null);
    this.doorOrWindowCheckBox.setValue(controller.getDoorOrWindow());
    final PropertyChangeListener doorOrWindowChangeListener = new PropertyChangeListener() {
      public void propertyChange(PropertyChangeEvent ev) {
        doorOrWindowCheckBox.setNullable(ev.getNewValue() == null);
        doorOrWindowCheckBox.setValue((Boolean)ev.getNewValue());
      }
    };
    controller.addPropertyChangeListener(FurnitureController.Property.DOOR_OR_WINDOW, doorOrWindowChangeListener);
    this.doorOrWindowCheckBox.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent ev) {
          controller.removePropertyChangeListener(FurnitureController.Property.DOOR_OR_WINDOW, doorOrWindowChangeListener);
          controller.setDoorOrWindow(doorOrWindowCheckBox.getValue());
          controller.addPropertyChangeListener(FurnitureController.Property.DOOR_OR_WINDOW, doorOrWindowChangeListener);
        }
      });
   
    // Create back face shown check box bound to BACK_FACE_SHOWN controller property
    this.backFaceShownCheckBox = new NullableCheckBox(SwingTools.getLocalizedLabelText(preferences,
        FurniturePanel.class, "backFaceShownCheckBox.text"));
    this.backFaceShownCheckBox.setNullable(controller.getBackFaceShown() == null);
    this.backFaceShownCheckBox.setValue(controller.getBackFaceShown());
    final PropertyChangeListener backFaceShownChangeListener = new PropertyChangeListener() {
      public void propertyChange(PropertyChangeEvent ev) {
        backFaceShownCheckBox.setNullable(ev.getNewValue() == null);
        backFaceShownCheckBox.setValue((Boolean)ev.getNewValue());
      }
    };
    controller.addPropertyChangeListener(FurnitureController.Property.BACK_FACE_SHOWN, backFaceShownChangeListener);
    this.backFaceShownCheckBox.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent ev) {
          controller.removePropertyChangeListener(FurnitureController.Property.BACK_FACE_SHOWN, backFaceShownChangeListener);
          controller.setBackFaceShown(backFaceShownCheckBox.getValue());
          resetIcon(false);
          controller.addPropertyChangeListener(FurnitureController.Property.BACK_FACE_SHOWN, backFaceShownChangeListener);
        }
      });
   
    // Create resizable check box bound to RESIZABLE controller property
    this.resizableCheckBox = new NullableCheckBox(SwingTools.getLocalizedLabelText(preferences,
        FurniturePanel.class, "resizableCheckBox.text"));
    this.resizableCheckBox.setNullable(controller.getResizable() == null);
    this.resizableCheckBox.setValue(controller.getResizable());
    final PropertyChangeListener resizableChangeListener = new PropertyChangeListener() {
      public void propertyChange(PropertyChangeEvent ev) {
        resizableCheckBox.setNullable(ev.getNewValue() == null);
        resizableCheckBox.setValue((Boolean)ev.getNewValue());
      }
    };
    controller.addPropertyChangeListener(FurnitureController.Property.RESIZABLE, resizableChangeListener);
    this.resizableCheckBox.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent ev) {
          controller.removePropertyChangeListener(FurnitureController.Property.RESIZABLE, resizableChangeListener);
          controller.setResizable(resizableCheckBox.getValue());
          controller.addPropertyChangeListener(FurnitureController.Property.RESIZABLE, resizableChangeListener);
        }
      });
   
    // Create deformable check box bound to DEFORMABLE controller property
    this.deformableCheckBox = new NullableCheckBox(SwingTools.getLocalizedLabelText(preferences,
        FurniturePanel.class, "deformableCheckBox.text"));
    this.deformableCheckBox.setNullable(controller.getDeformable() == null);
    this.deformableCheckBox.setValue(controller.getDeformable());
    final PropertyChangeListener deformableChangeListener = new PropertyChangeListener() {
      public void propertyChange(PropertyChangeEvent ev) {
        deformableCheckBox.setNullable(ev.getNewValue() == null);
        deformableCheckBox.setValue((Boolean)ev.getNewValue());
      }
    };
    controller.addPropertyChangeListener(FurnitureController.Property.DEFORMABLE, deformableChangeListener);
    this.deformableCheckBox.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent ev) {
          controller.removePropertyChangeListener(FurnitureController.Property.DEFORMABLE, deformableChangeListener);
          controller.setDeformable(deformableCheckBox.getValue());
          controller.addPropertyChangeListener(FurnitureController.Property.DEFORMABLE, deformableChangeListener);
        }
View Full Code Here


    JPanel p3 = new JPanel();
    p3.setBorder(BorderFactory.createTitledBorder("Clusterer output"));
    p3.setLayout(new BorderLayout());
    final JScrollPane js = new JScrollPane(m_OutText);
    p3.add(js, BorderLayout.CENTER);
    js.getViewport().addChangeListener(new ChangeListener() {
      private int lastHeight;
      public void stateChanged(ChangeEvent e) {
  JViewport vp = (JViewport)e.getSource();
  int h = vp.getViewSize().height;
  if (h != lastHeight) { // i.e. an addition not just a user scrolling
View Full Code Here

    formatPanel.addRow();
    final JLabel bodyLabel = new JLabel(ProgramInfo.mLocalizer.msg("body", "Description font"));
    formatPanel.add(bodyLabel, cc.xy(3,formatPanel.getRowCount()));
    formatPanel.add(mBodyFont, cc.xyw(6,formatPanel.getRowCount(),2));

    mUserFont.addChangeListener(new ChangeListener() {
      public void stateChanged(ChangeEvent e) {
        mTitleFont.setEnabled(mUserFont.isSelected());
        mBodyFont.setEnabled(mUserFont.isSelected());
        titleLabel.setEnabled(mUserFont.isSelected());
        bodyLabel.setEnabled(mUserFont.isSelected());
View Full Code Here

    JPanel p3 = new JPanel();
    p3.setBorder(BorderFactory.createTitledBorder("Classifier output"));
    p3.setLayout(new BorderLayout());
    final JScrollPane js = new JScrollPane(m_OutText);
    p3.add(js, BorderLayout.CENTER);
    js.getViewport().addChangeListener(new ChangeListener() {
      private int lastHeight;
      public void stateChanged(ChangeEvent e) {
  JViewport vp = (JViewport)e.getSource();
  int h = vp.getViewSize().height;
  if (h != lastHeight) { // i.e. an addition not just a user scrolling
View Full Code Here

     
      size = new Dimension(500, 400);
      m_costBenefitPanel.setMinimumSize(size);
      m_costBenefitPanel.setPreferredSize(size);
     
      m_thresholdSlider.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
          updateInfoForSliderValue((double)m_thresholdSlider.getValue() / 100.0);
        }
      });
     
View Full Code Here

        scroll.setColumnHeaderView(columnHeader);

        JPanel timeNorthPanel = new JPanel();
        calendarDateField = CalendarFactory.createDateField();
        calendarDateField.addChangeListener(new ChangeListener() {

            @Override
            public void stateChanged(ChangeEvent e) {
                // get the date only - not the time
                DateTime val = new DateTime(((Date) calendarDateField.getValue()).getTime());
View Full Code Here

        }
        if (tabLayoutPolicy != -1) {
            tabbedPane.setTabLayoutPolicy(tabLayoutPolicy);
        }

        tabbedPane.addChangeListener(new ChangeListener() {

            public void stateChanged(ChangeEvent e) {
                // if we're adding a component, ignore change of active component
                if (!addingComponent && tabbedPane.getSelectedIndex() >= 0) {
                    setActiveComponent(getComponent(tabbedPane.getSelectedIndex()));
View Full Code Here

      Dimension d = treeView.getPreferredSize();
      d = new Dimension((int)(d.getWidth() * 1.5), (int)d.getHeight());
      treeView.setPreferredSize(d);
      treeView.setMinimumSize(d);

      m_flowTabs.addChangeListener(new ChangeListener() {
        // This method is called whenever the selected tab changes
        public void stateChanged(ChangeEvent evt) {

          // Get current tab
          int sel = m_flowTabs.getSelectedIndex();
View Full Code Here

            Program program = (Program) value;
            Insets borderInsets = label.getBorder().getBorderInsets(label);
            mProgramPanel.setWidth(table.getCellRect(row, column, false).width - borderInsets.left - borderInsets.right);
            mProgramPanel.setProgram(program);
           
            program.addChangeListener(new ChangeListener() {
              public void stateChanged(ChangeEvent e) {
                table.repaint();
              }
            });
           
View Full Code Here

      setReport(report);

      final ChangeEvent event = new ChangeEvent(this);
      for (int i = 0; i < changeListeners.size(); i++)
      {
        final ChangeListener listener = changeListeners.get(i);
        listener.stateChanged(event);
      }
    }
    catch (ReportProcessingException e)
    {
      ExceptionDialog.showExceptionDialog(this,
View Full Code Here

TOP

Related Classes of javax.swing.event.ChangeListener

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.