List of usage examples for javax.swing.event ChangeEvent getSource
public Object getSource()
From source file:UndoExample5.java
public UndoExample5() { super("Undo/Redo Example 5"); pane = new JTextPane(); pane.setEditable(true); // Editable getContentPane().add(new JScrollPane(pane), BorderLayout.CENTER); // Add a menu bar menuBar = new JMenuBar(); setJMenuBar(menuBar);/* ww w . java2 s. c om*/ // Populate the menu bar createMenuBar(); // Create the undo manager and actions MonitorableUndoManager manager = new MonitorableUndoManager(); pane.getDocument().addUndoableEditListener(manager); Action undoAction = new UndoAction(manager); Action redoAction = new RedoAction(manager); // Add the actions to buttons JPanel panel = new JPanel(); final JButton undoButton = new JButton("Undo"); final JButton redoButton = new JButton("Redo"); undoButton.addActionListener(undoAction); redoButton.addActionListener(redoAction); undoButton.setEnabled(false); redoButton.setEnabled(false); panel.add(undoButton); panel.add(redoButton); getContentPane().add(panel, BorderLayout.SOUTH); // Assign the actions to keys pane.registerKeyboardAction(undoAction, KeyStroke.getKeyStroke(KeyEvent.VK_Z, InputEvent.CTRL_MASK), JComponent.WHEN_FOCUSED); pane.registerKeyboardAction(redoAction, KeyStroke.getKeyStroke(KeyEvent.VK_Y, InputEvent.CTRL_MASK), JComponent.WHEN_FOCUSED); // Handle events from the MonitorableUndoManager manager.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent evt) { MonitorableUndoManager m = (MonitorableUndoManager) evt.getSource(); boolean canUndo = m.canUndo(); boolean canRedo = m.canRedo(); undoButton.setEnabled(canUndo); redoButton.setEnabled(canRedo); undoButton.setToolTipText(canUndo ? m.getUndoPresentationName() : null); redoButton.setToolTipText(canRedo ? m.getRedoPresentationName() : null); } }); }
From source file:de.unibayreuth.bayeos.goat.options.JOptionDialog.java
private void jspGapThresholdStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jspGapThresholdStateChanged JSpinner s = (JSpinner) evt.getSource(); SpinnerNumberModel m = (SpinnerNumberModel) s.getModel(); pref.putDouble("chartthreshold", m.getNumber().doubleValue()); }
From source file:de.unibayreuth.bayeos.goat.options.JOptionDialog.java
private void jspMaxRecNumberStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jspMaxRecNumberStateChanged JSpinner s = (JSpinner) evt.getSource(); SpinnerNumberModel m = (SpinnerNumberModel) s.getModel(); pref.putInt("maxrecnumber", m.getNumber().intValue()); }
From source file:de.unibayreuth.bayeos.goat.options.JOptionDialog.java
private void jSliderShapeSizeStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jSliderShapeSizeStateChanged JSlider s = (JSlider) evt.getSource(); if (!s.getValueIsAdjusting()) { pref.putInt("shapesize", s.getValue()); }//from w ww . j a v a 2s . co m }
From source file:edu.ku.brc.specify.tasks.subpane.wb.EditFormControlDlg.java
public void stateChanged(ChangeEvent e) { changeTracker.put(e.getSource(), true); }
From source file:eremeykin.pete.plotter.PolarPlotterTopComponent.java
private void jSpinner1StateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jSpinner1StateChanged // TODO add your handling code here: JSpinner source = (JSpinner) (evt.getSource()); scale = Double.valueOf(source.getValue().toString()); update();//from w w w . j av a 2s .c o m }
From source file:at.tuwien.ifs.somtoolbox.apps.viewer.controls.DendogramView.java
/** * @param t//ww w .j a v a2 s . c om * @param numClusters2 */ public void update(ClusteringTree t, int numClusters) { frame.setVisible(true); frame.getContentPane().removeAll(); try { // create spinner-panel clusterPanel = UiUtils.makeBorderedPanel(new FlowLayout(FlowLayout.LEFT, 10, 0), "Clusters"); spinnerCluster = new JSpinner(new SpinnerNumberModel(1, 1, maxCluster, 1)); spinnerCluster.setValue(numClusters); spinnerCluster.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { if (mMainSpinnerCluster != null) { mMainSpinnerCluster.setValue(((JSpinner) e.getSource()).getValue()); } } }); UiUtils.fillPanel(clusterPanel, new JLabel("#"), spinnerCluster); frame.getContentPane().add(clusterPanel, BorderLayout.NORTH); // create graph VisualizationViewer g = generateGraph(t, numClusters); frame.getContentPane().add(g, BorderLayout.CENTER); frame.setSize(frame.getWidth() + 1, frame.getHeight() + 1); frame.setSize(frame.getWidth() - 1, frame.getHeight() - 1); } catch (Exception e) { e.printStackTrace(); } }
From source file:net.sf.maltcms.chromaui.ui.PaintScalePanel.java
@Override public void stateChanged(ChangeEvent ce) { if (ce.getSource() == this.jSlider1 || ce.getSource() == this.jSlider2) { PaintScale psc = ((PaintScaleLabel) this.jLabel4).getPaintScale(); if (psc instanceof GradientPaintScale) { ((GradientPaintScale) psc).setAlphaBeta(getAlpha(), getBeta()); RepaintManager.currentManager(this.jLabel4).markCompletelyDirty(this.jLabel4); }//from w w w . j ava 2 s .c o m } // System.out.println("Alpha value: " + getAlpha()); // System.out.println("Beta value: " + getBeta()); }
From source file:AtomPanel.java
/** Listen to the slider. */ public void stateChanged(ChangeEvent e) { JSlider source = (JSlider) e.getSource(); if ("faRate".equals(source.getName())) { if (!source.getValueIsAdjusting()) { double L = (double) source.getValue(); falseAlarmRate = 0.001 * L; // L is 1-10, map it to 0.001-0.01 }/*from w w w . j a v a2s. c o m*/ } else if ("wdSz".equals(source.getName())) { //"window size" if (!source.getValueIsAdjusting()) { double L = (double) source.getValue(); wdSz = 20 * (int) (L); // L is 1-10, map it to 40-400 } } else if ("delta".equals(source.getName())) { //"delta" if (!source.getValueIsAdjusting()) { double L = (double) source.getValue(); percent = 0.02 * (L - 1); // L is 1-10, map it to 0-0.2 } } else if ("devbnd".equals(source.getName())) { //"deviation bound" if (!source.getValueIsAdjusting()) { double L = (double) source.getValue(); devBnd = 0.001 * (L - 1) / 9; // L is 1-10, map it to 0-0.01 } } }
From source file:Human1.java
public void stateChanged(ChangeEvent e) { JSlider source = (JSlider) e.getSource(); int value = source.getValue(); if (source == rShoulderSlider) { setRShoulderRot(value);/*from w w w. j a v a 2 s . com*/ rShoulderSliderLabel.setText(Integer.toString(value)); } else if (source == rElbowSlider) { setRElbowRot(value); rElbowSliderLabel.setText(Integer.toString(value)); } else if (source == lShoulderSlider) { setLShoulderRot(value); lShoulderSliderLabel.setText(Integer.toString(value)); } else if (source == lElbowSlider) { setLElbowRot(value); lElbowSliderLabel.setText(Integer.toString(value)); } }