javax.swing.event.ChangeEvent Java Examples

The following examples show how to use javax.swing.event.ChangeEvent. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MultiGradientTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private ControlsPanel() {
    cmbPaint = createCombo(this, paintType);
    cmbPaint.setSelectedIndex(1);
    cmbCycle = createCombo(this, cycleMethod);
    cmbSpace = createCombo(this, colorSpace);
    cmbShape = createCombo(this, shapeType);
    cmbXform = createCombo(this, xformType);

    int max = COLORS.length;
    SpinnerNumberModel model = new SpinnerNumberModel(max, 2, max, 1);
    spinNumColors = new JSpinner(model);
    spinNumColors.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            numColors = ((Integer)spinNumColors.getValue()).intValue();
            gradientPanel.updatePaint();
        }
    });
    add(spinNumColors);

    cbAntialias = createCheck(this, "Antialiasing");
    cbRender = createCheck(this, "Render Quality");
}
 
Example #2
Source File: FontStringPropertyEditor.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Invoked when the target of the listener has changed its state.
 *
 * @param e a ChangeEvent object
 */
public void stateChanged( final ChangeEvent e ) {
  final String fontName = basicFontPropertiesPane.getFontFamily();
  final int fontSize = basicFontPropertiesPane.getFontSize();
  final int fontStyle = basicFontPropertiesPane.getFontStyle();
  final String fontStyleText;
  if ( ( fontStyle & ( Font.BOLD | Font.ITALIC ) ) == ( Font.BOLD | Font.ITALIC ) ) {
    fontStyleText = "BOLDITALIC";
  } else if ( ( fontStyle & Font.BOLD ) == Font.BOLD ) {
    fontStyleText = "BOLD";
  } else if ( ( fontStyle & Font.ITALIC ) == Font.ITALIC ) {
    fontStyleText = "ITALIC";
  } else {
    fontStyleText = "PLAIN";
  }
  setValue( fontName + "-" + fontStyleText + "-" + fontSize );
}
 
Example #3
Source File: ConnectTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void waitForInit (final RemoteRepository repository) throws InterruptedException {
    final boolean[] valid = new boolean[1];
    repository.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged (ChangeEvent e) {
            EventQueue.invokeLater(new Runnable() {
                @Override
                public void run () {
                    valid[0] = repository.isValid();
                }
            });
        }
    });
    for (int i = 0; i < 100; ++i) {
        if (valid[0]) {
            break;
        }
        Thread.sleep(100);
    }
}
 
Example #4
Source File: MainGradlePanel.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void setupUI() {
    setLayout(new BorderLayout());

    tabbedPane = new JTabbedPane();
    add(tabbedPane, BorderLayout.CENTER);

    addTabs();

    restoreLastTab();

    //add a listener so we can store the current tab when it changes.
    tabbedPane.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            int selection = tabbedPane.getSelectedIndex();
            if (selection >= 0 && selection < gradleTabs.size()) {
                SettingsNode rootNode = settings.addChildIfNotPresent(MAIN_PANEL);
                rootNode.setValueOfChild(CURRENT_TAB, gradleTabs.get(selection).getName());
            }
        }
    });
}
 
Example #5
Source File: ColorPick.java    From Spark with Apache License 2.0 6 votes vote down vote up
@Override
   public void stateChanged(ChangeEvent e) {

_preview.setBackground(new Color(_sliderarray[0].getValue(), _sliderarray[1].getValue(), _sliderarray[2]
	.getValue(), _sliderarray[3].getValue()));

_preview.setForeground(new Color(_sliderarray[0].getValue(), _sliderarray[1].getValue(), _sliderarray[2]
	.getValue(), _sliderarray[3].getValue()));

_preview.invalidate();
_preview.repaint();
_preview.revalidate();

Container c = _preview.getParent();
if (c instanceof JPanel) {
    c.repaint();
    c.revalidate();
}
   }
 
Example #6
Source File: FlutterLogView.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public void stateChanged(ChangeEvent e) {
  if (e.getSource() instanceof BoundedRangeModel) {
    final BoundedRangeModel model = (BoundedRangeModel)e.getSource();
    final int newScrollValue = model.getValue();
    final boolean isScrollUp = newScrollValue < oldScrollValue;
    final boolean isScrollToEnd = newScrollValue + model.getExtent() == model.getMaximum();
    if (isScrollUp) {
      onScrollUp();
    }
    else if (isScrollToEnd) {
      onScrollToEnd();
    }
    oldScrollValue = newScrollValue;
  }
}
 
Example #7
Source File: ModelBuilder.java    From tracker with GNU General Public License v3.0 6 votes vote down vote up
ModelFrameSpinner(SpinnerNumberModel model) {
	super(model);
	spinModel = model;
  	prevMax = (Integer)spinModel.getMaximum();
		addChangeListener(new ChangeListener() {
      public void stateChanged(ChangeEvent e) {
      	ModelFunctionPanel panel = (ModelFunctionPanel)getSelectedPanel();
      	if (panel==null || panel.model==null || panel.model.refreshing)
      		return;
      	// do nothing if max has changed
      	if (prevMax!=spinModel.getMaximum()) {
      		prevMax = (Integer)spinModel.getMaximum();
      		return;
      	}
      	// otherwise set model start or end frame
    		int n = (Integer)getValue();
      	if (ModelFrameSpinner.this==startFrameSpinner)
      		panel.model.setStartFrame(n);
      	else
      		panel.model.setEndFrame(n);
      }
    });
}
 
Example #8
Source File: AudioScopeView.java    From jsyn with Apache License 2.0 6 votes vote down vote up
public void setModel(AudioScopeModel audioScopeModel) {
    this.audioScopeModel = audioScopeModel;
    // Create a view for each probe.
    probeViews.clear();
    for (AudioScopeProbe probeModel : audioScopeModel.getProbes()) {
        AudioScopeProbeView audioScopeProbeView = new AudioScopeProbeView(probeModel);
        probeViews.add(audioScopeProbeView);
    }
    setupGUI();

    // Listener for signal change events.
    audioScopeModel.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            multipleWaveDisplay.repaint();
        }
    });

}
 
Example #9
Source File: TreeSidePanel.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
public void stateChanged( final ChangeEvent e ) {
  final ElementPropertiesPanel attributeEditorPanel = getAttributeEditorPanel();
  if ( attributeEditorPanel == null ) {
    return;
  }
  final ReportDocumentContext activeContext = context.getActiveContext();
  if ( activeContext == null ) {
    return;
  }
  final JTabbedPane tabs = (JTabbedPane) e.getSource();
  if ( tabs.getSelectedIndex() == 0 ) {
    refreshTabPanel( attributeEditorPanel, activeContext, true, false, false );
  } else {
    refreshTabPanel( attributeEditorPanel, activeContext, false, true, true );
  }
}
 
Example #10
Source File: CommonSettingsDialog.java    From megamek with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void stateChanged(ChangeEvent evt) {
    GUIPreferences guip = GUIPreferences.getInstance();
    if (evt.getSource().equals(fovHighlightAlpha)) {
        // Need to convert from 0-100 to 0-255
        guip.setFovHighlightAlpha((int) (fovHighlightAlpha.getValue() * 2.55));
        if ((clientgui != null) && (clientgui.bv != null)) {
            clientgui.bv.clearHexImageCache();
            clientgui.bv.repaint();
        }
    } else if (evt.getSource().equals(fovDarkenAlpha)) {
        // Need to convert from 0-100 to 0-255
        guip.setFovDarkenAlpha((int) (fovDarkenAlpha.getValue() * 2.55));
        if ((clientgui != null) && (clientgui.bv != null)) {
            clientgui.bv.clearHexImageCache();
            clientgui.bv.repaint();
        }
    } else if (evt.getSource().equals(numStripesSlider)) {
        guip.setFovStripes(numStripesSlider.getValue());
        if ((clientgui != null) && (clientgui.bv != null)) {
            clientgui.bv.clearHexImageCache();
            clientgui.bv.repaint();
        }
    }
}
 
Example #11
Source File: MainGradlePanel.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void setupUI() {
    setLayout(new BorderLayout());

    tabbedPane = new JTabbedPane();
    add(tabbedPane, BorderLayout.CENTER);

    addTabs();

    restoreLastTab();

    //add a listener so we can store the current tab when it changes.
    tabbedPane.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            int selection = tabbedPane.getSelectedIndex();
            if (selection >= 0 && selection < gradleTabs.size()) {
                SettingsNode rootNode = settings.addChildIfNotPresent(MAIN_PANEL);
                rootNode.setValueOfChild(CURRENT_TAB, gradleTabs.get(selection).getName());
            }
        }
    });
}
 
Example #12
Source File: SimulationToolbarModel.java    From Logisim with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void stateChanged(ChangeEvent e) {
	Simulator sim = project.getSimulator();
	boolean running = sim != null && sim.isRunning();
	boolean ticking = sim != null && sim.isTicking();
	simEnable.setIcon(running ? "simstop.png" : "simplay.png");
	simEnable.setToolTip(
			running ? Strings.getter("simulateDisableStepsTip") : Strings.getter("simulateEnableStepsTip"));
	tickEnable.setIcon(ticking ? "simtstop.png" : "simtplay.png");
	tickEnable.setToolTip(
			ticking ? Strings.getter("simulateDisableTicksTip") : Strings.getter("simulateEnableTicksTip"));
	fireToolbarAppearanceChanged();
}
 
Example #13
Source File: ColorButton.java    From PyramidShader with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates a new instance of ColorButton. Default color is black, default
 * size of the icon is 16 x 16 pixels. This button is registered with itself
 * for receiving action performed calls.
 */
public ColorButton() {
    this.color = new Color(0, 0, 0);
    this.iconHeight = 16;
    this.iconWidth = 16;
    this.colorChooserTitle = "Choose a Color";

    //Set up the dialog that the button brings up.
    colorChooser = new JColorChooser();

    // replace the ugly and useless preview panel by an empty JPanel
    colorChooser.setPreviewPanel(new JPanel());

    // remove the swatch
    AbstractColorChooserPanel[] choosers = colorChooser.getChooserPanels();
    for (AbstractColorChooserPanel chooser : choosers) {
        String clsName = chooser.getClass().getName();
        if (clsName.equals("javax.swing.colorchooser.DefaultSwatchChooserPanel")) {
            colorChooser.removeChooserPanel(chooser);
        }
    }

    ColorSelectionModel colorSelectionModel = colorChooser.getSelectionModel();
    colorSelectionModel.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent evt) {
            ColorSelectionModel model = (ColorSelectionModel) evt.getSource();
            setColor(model.getSelectedColor());
        }
    });

    this.updateIcon();
}
 
Example #14
Source File: Model.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Fires an state change event every time the data model changes
 */
protected void fireStateChanged() {
    Object[] listeners = LISTENER_LIST.getListenerList();

    // Process the listeners last to first, notifying
    // those that are interested in this event
    for (int i = listeners.length - 2; i >= 0; i -= 2) {
        if (listeners[i] == javax.swing.event.ChangeListener.class) {
            if (changeEvent == null) {
                changeEvent = new javax.swing.event.ChangeEvent(this);
            }
            ((javax.swing.event.ChangeListener) listeners[i + 1]).stateChanged(changeEvent);
        }
    }
}
 
Example #15
Source File: EULADialog.java    From rapidminer-studio with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Listens to changes of the check box, enables the accept button when the check box is active.
 */
@Override
public void stateChanged(ChangeEvent e) {
	if (e.getSource() == this.acceptCheckBox) {
		this.acceptButton.setEnabled(this.acceptCheckBox.isSelected());
	}
}
 
Example #16
Source File: PhpDocOptionsPanelController.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void stateChanged(ChangeEvent e) {
    if (!changed) {
        changed = true;
        propertyChangeSupport.firePropertyChange(OptionsPanelController.PROP_CHANGED, false, true);
    }
    propertyChangeSupport.firePropertyChange(OptionsPanelController.PROP_VALID, null, null);
}
 
Example #17
Source File: AddServerLocationPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void fireChangeEvent(ChangeEvent ev) {
    Iterator it;
    synchronized (listeners) {
        it = new HashSet(listeners).iterator();
    }
    while (it.hasNext()) {
        ((ChangeListener)it.next()).stateChanged(ev);
    }
}
 
Example #18
Source File: AndroidProjectTemplateWizardPanelWearActivityAndroidSettings.java    From NBANDROID-V2 with Apache License 2.0 5 votes vote down vote up
protected final void fireChangeEvent() {
    wizardDescriptor.putProperty(PROP_WEAR_CONFIG, component.getCurrentTemplate() != null);
    Set<ChangeListener> ls;
    synchronized (listeners) {
        ls = new HashSet<ChangeListener>(listeners);
    }
    ChangeEvent ev = new ChangeEvent(this);
    for (ChangeListener l : ls) {
        l.stateChanged(ev);
    }
}
 
Example #19
Source File: SymfonyOptionsPanelController.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void stateChanged(ChangeEvent e) {
    if (!changed) {
        changed = true;
        propertyChangeSupport.firePropertyChange(OptionsPanelController.PROP_CHANGED, false, true);
    }
    propertyChangeSupport.firePropertyChange(OptionsPanelController.PROP_VALID, null, null);
}
 
Example #20
Source File: SearchPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void init(Presenter explicitPresenter) {

        presenters = makePresenters(explicitPresenter);
        setLayout(new GridLayout(1, 1));

        if (presenters.isEmpty()) {
            throw new IllegalStateException("No presenter found");      //NOI18N
        } else if (presenters.size() == 1) {
            selectedPresenter = presenters.get(0).getPresenter();
            add(selectedPresenter.getForm());
        } else {
            tabbedPane = new JTabbedPane();
            for (PresenterProxy pp : presenters) {
                Component tab = tabbedPane.add(pp.getForm());
                if (pp.isInitialized()) {
                    tabbedPane.setSelectedComponent(tab);
                    selectedPresenter = pp.getPresenter();
                }
            }
            tabbedPane.addChangeListener(new ChangeListener() {
                @Override
                public void stateChanged(ChangeEvent e) {
                    tabChanged();
                }
            });
            add(tabbedPane);
        }
        if (selectedPresenter == null) {
            chooseLastUsedPresenter();
        }
        newTabCheckBox = new JCheckBox(NbBundle.getMessage(SearchPanel.class,
                "TEXT_BUTTON_NEW_TAB"));                                //NOI18N
        newTabCheckBox.setMaximumSize(new Dimension(1000, 200));
        newTabCheckBox.setSelected(
                FindDialogMemory.getDefault().isOpenInNewTab());
        initLocalStrings();
        initAccessibility();
    }
 
Example #21
Source File: LineChartAnnotationDialog.java    From nmonvisualizer with Apache License 2.0 5 votes vote down vote up
@Override
public void stateChanged(ChangeEvent e) {
    // for xAxisTime
    if (useXAxisValue.isSelected()) {
        annotation.setText(((DateEditor) xAxisTime.getEditor()).getFormat().format(xAxisTime.getValue()));
    }
}
 
Example #22
Source File: PageableTable.java    From jdal with Apache License 2.0 5 votes vote down vote up
/**
 * Notify ChangeListeners that state change
 */
private void fireChangeEvent()  {
	ChangeEvent e = new ChangeEvent(this);
	
	for (ChangeListener l : changeListeners)
		l.stateChanged(e);
}
 
Example #23
Source File: NinePatchEditor.java    From weblaf with GNU General Public License v3.0 5 votes vote down vote up
private void fireStateChanged ()
{
    final ChangeEvent changeEvent = new ChangeEvent ( NinePatchEditor.this );
    for ( final ChangeListener listener : CollectionUtils.copy ( changeListeners ) )
    {
        listener.stateChanged ( changeEvent );
    }
}
 
Example #24
Source File: HeapWalker.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private static void setProgress(final ProgressHandle pHandle, final int offset) {
    final BoundedRangeModel progress = HeapProgress.getProgress();
    progress.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            pHandle.progress(progress.getValue()+offset);
        }
    });
}
 
Example #25
Source File: DirectoryTable.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Override
public void editingStopped(ChangeEvent e) {
	super.editingStopped(e);
	Object source = e.getSource();
	final FileEditor fileCellEditor = (FileEditor) source;
	SwingUtilities.invokeLater(() -> {
		File newFile = (File) fileCellEditor.getCellEditorValue();
		chooser.setSelectedFileAndUpdateDisplay(newFile);
		rowToEdit = -1;
	});
}
 
Example #26
Source File: ToggleButtonDemo.java    From beautyeye with Apache License 2.0 5 votes vote down vote up
public void stateChanged(ChangeEvent e) {
    SingleSelectionModel model = (SingleSelectionModel) e.getSource();
    if (model.getSelectedIndex() == 0) {
        currentControls = buttons;
    } else if (model.getSelectedIndex() == 1) {
        currentControls = radiobuttons;
    } else if (model.getSelectedIndex() == 2) {
        currentControls = checkboxes;
    } else {
        currentControls = togglebuttons;
    }
}
 
Example #27
Source File: DocumentControls.java    From pumpernickel with MIT License 5 votes vote down vote up
protected void fireChangeListeners() {
	ChangeListener[] listenerArray;
	synchronized (changeListeners) {
		listenerArray = this.changeListeners
				.toArray(new ChangeListener[changeListeners.size()]);
	}
	for (ChangeListener l : listenerArray) {
		try {
			l.stateChanged(new ChangeEvent(this));
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
 
Example #28
Source File: Hk2InstanceChildren.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void stateChanged(ChangeEvent e) {
    Mutex.EVENT.readAccess(new Runnable() {
        @Override
        public void run() {
            updateKeys();
        }
    });
}
 
Example #29
Source File: ExcludeDependencyPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void stateChanged(ChangeEvent e) {
    CheckNode trans = change2Trans.get(this);
    List<CheckNode> refs = change2Refs.get(this);
    boolean all = true;
    boolean some = false;
    for (CheckNode ref : refs) {
        if (!ref.isSelected()) {
            all = false;
        }
        if (ref.isSelected()) {
            some = true;
        }
    }
    if (all) {
        //competely gone.. -> strikethrough
        trans.strike();
    } else {
        trans.unstrike();
    }
    if (some) {
        trans.italic();
    } else {
        trans.unitalic();
    }
    if (trTrans.isVisible()) {
        trTrans.repaint();
    }
}
 
Example #30
Source File: PaletteEditor.java    From lsdpatch with MIT License 5 votes vote down vote up
public void stateChanged(ChangeEvent e) {
    // Spinner changed.
    if (!updatingSpinners) {
        updateRomFromSpinners();
        updatePreviewPanes();
    }
}