Java Code Examples for javax.swing.event.ChangeEvent

The following examples show how to use javax.swing.event.ChangeEvent. These examples are extracted from open source projects. 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 Project: megamek   Source File: CommonSettingsDialog.java    License: 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 2
@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 3
Source Project: tracker   Source File: ModelBuilder.java    License: 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 4
Source Project: jsyn   Source File: AudioScopeView.java    License: 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 5
Source Project: Spark   Source File: ColorPick.java    License: 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
/**
 * 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 7
Source Project: netbeans   Source File: ConnectTest.java    License: 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 8
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 9
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 10
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 11
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 12
Source Project: PyramidShader   Source File: ColorButton.java    License: 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 13
Source Project: nmonvisualizer   Source File: LineChartAnnotationDialog.java    License: 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 14
Source Project: audiveris   Source File: Zoom.java    License: GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Define a related logarithmic slider, as a UI to adjust the zoom
 * value
 *
 * @param slider the related slider UI
 */
public final void setSlider (final LogSlider slider)
{
    this.slider = slider;
    logger.debug("setSlider");

    if (slider != null) {
        slider.setFocusable(false);
        slider.setDoubleValue(ratio);

        slider.addChangeListener(new ChangeListener()
        {
            @Override
            public void stateChanged (ChangeEvent e)
            {
                // Forward the new zoom ratio
                if (constants.continuousSliderReading.getValue() || !slider
                        .getValueIsAdjusting()) {
                    double newRatio = slider.getDoubleValue();
                    logger.debug("Slider firing zoom newRatio={}", newRatio);

                    // Stop condition to avoid endless loop between
                    // slider and zoom
                    if (Math.abs(newRatio - ratio) > .001) {
                        forceRatio(newRatio);
                    }
                }
            }
        });
    }
}
 
Example 15
Source Project: darklaf   Source File: TabbedPaneHandler.java    License: MIT License 5 votes vote down vote up
public void stateChanged(final ChangeEvent e) {
    JTabbedPane tabPane = (JTabbedPane) e.getSource();
    tabPane.revalidate();
    tabPane.repaint();

    ui.setFocusIndex(tabPane.getSelectedIndex(), false);

    if (ui.scrollableTabLayoutEnabled()) {
        ui.ensureCurrentLayout();
        int index = tabPane.getSelectedIndex();
        if (index < ui.rects.length && index != -1) {
            ui.tabScroller.tabPanel.scrollRectToVisible((Rectangle) ui.rects[index].clone());
        }
    }
}
 
Example 16
Source Project: ghidra   Source File: FunctionMerger.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void stateChanged(ChangeEvent e) {
	ResolveConflictChangeEvent re = (ResolveConflictChangeEvent) e;
	int choice = re.getChoice();
	try {
		mergeOverlap(entryPt, getOptionForChoice(choice), currentMonitor);
	}
	catch (CancelledException e1) {
		Msg.error(this, "Unexpected Exception: " + e1.getMessage(), e1);
	}
	adjustUseForAll();
	adjustApply();
}
 
Example 17
Source Project: pumpernickel   Source File: ModifierTracker.java    License: MIT License 5 votes vote down vote up
private static void fireControlChangeListeners() {
	if (ctrlListeners == null)
		return;
	for (int a = 0; a < ctrlListeners.size(); a++) {
		ChangeListener l = ctrlListeners.get(a);
		try {
			l.stateChanged(new ChangeEvent(ModifierTracker.class));
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
 
Example 18
Source Project: netbeans   Source File: SymfonyOptionsPanelController.java    License: 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 19
Source Project: mars-sim   Source File: Model.java    License: 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 20
Source Project: netbeans   Source File: ManagedBeanIterator.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void initialize(TemplateWizard wizard) {
    index = 0;
    // obtaining target folder
    Project project = Templates.getProject(wizard);

    SourceGroup[] sourceGroups = ProjectUtils.getSources(project).getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
    managedBeanPanel = new ManagedBeanPanel(project, wizard);
    WizardDescriptor.Panel javaPanel;
    if (sourceGroups.length == 0) {
        wizard.putProperty(WizardDescriptor.PROP_ERROR_MESSAGE, NbBundle.getMessage(ManagedBeanIterator.class, "MSG_No_Sources_found"));
        javaPanel = managedBeanPanel;
    } else {
        javaPanel = JavaTemplates.createPackageChooser(project, sourceGroups, managedBeanPanel);

        javaPanel.addChangeListener(new ChangeListener() {
            @Override
            public void stateChanged(ChangeEvent e) {
                managedBeanPanel.updateManagedBeanName((WizardDescriptor.Panel) e.getSource());
            }
        });
    }
    panels = new WizardDescriptor.Panel[]{javaPanel};

    // Creating steps.
    Object prop = wizard.getProperty(WizardDescriptor.PROP_CONTENT_DATA); // NOI18N
    String[] beforeSteps = null;
    if (prop != null && prop instanceof String[]) {
        beforeSteps = (String[]) prop;
    }
    String[] steps = createSteps(beforeSteps, panels);
    for (int i = 0; i < panels.length; i++) {
        JComponent jc = (JComponent) panels[i].getComponent();
        if (steps[i] == null) {
            steps[i] = jc.getName();
        }
        jc.putClientProperty(WizardDescriptor.PROP_CONTENT_SELECTED_INDEX, new Integer(i)); // NOI18N
        jc.putClientProperty(WizardDescriptor.PROP_CONTENT_DATA, steps); // NOI18N
    }
}
 
Example 21
Source Project: netbeans   Source File: PHPSamplesWizardPanel.java    License: Apache License 2.0 5 votes vote down vote up
protected final void fireChangeEvent() {
    Set<ChangeListener> ls;
    synchronized (listeners) {
        ls = new HashSet<ChangeListener>(listeners);
    }
    ChangeEvent ev = new ChangeEvent(this);
    for (ChangeListener l : ls) {
        l.stateChanged(ev);
    }
}
 
Example 22
Source Project: pumpernickel   Source File: ModifierTracker.java    License: MIT License 5 votes vote down vote up
private static void fireMetaChangeListeners() {
	if (metaListeners == null)
		return;
	for (int a = 0; a < metaListeners.size(); a++) {
		ChangeListener l = metaListeners.get(a);
		try {
			l.stateChanged(new ChangeEvent(ModifierTracker.class));
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
 
Example 23
Source Project: ET_Redux   Source File: TripoliSessionRawDataView.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void stateChanged(ChangeEvent e) {
    JSlider source = (JSlider) e.getSource();
    if (!source.getValueIsAdjusting()) {
        int value = source.getValue();
        if (FRACTION_LAYOUT_VIEW_STYLE.equals(FractionLayoutViewStylesEnum.SESSION)) {
            sessionModelWidth = value;
            SAVED_SessionModelWidth = value;
        } else {
            dataModelWidth = value;
            if (tripoliSession.getFractionationTechnique().compareTo(FractionationTechniquesEnum.INTERCEPT) == 0) {
                if (FRACTION_LAYOUT_VIEW_STYLE.equals(FractionLayoutViewStylesEnum.OVERLAY)) {
                    SAVED_InterceptOverlayModelWidth = value;
                } else {
                    SAVED_InterceptNormalModelWidth = value;
                }
            } else if (FRACTION_LAYOUT_VIEW_STYLE.equals(FractionLayoutViewStylesEnum.OVERLAY)) {
                SAVED_DownholeOverlayModelWidth = value;
            } else {
                SAVED_DownholeNormalModelWidth = value;
            }
        }
        if (!isZoomSlidersIndependent()) {
            theOtherSlider.setValue(value);
        }
        ((AbstractRawDataView) sampleSessionDataView).refreshPanel(true, false);
        sessionAnalysisWorkflowManager.revalidateScrollPane();
    }
}
 
Example 24
/**
 * 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 25
Source Project: netbeans   Source File: PhpDocOptionsPanelController.java    License: 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 26
Source Project: netbeans   Source File: SearchPanel.java    License: 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 27
Source Project: weblaf   Source File: NinePatchEditor.java    License: 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 28
Source Project: beautyeye   Source File: ToggleButtonDemo.java    License: 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 29
Source Project: pumpernickel   Source File: DocumentControls.java    License: 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 30
Source Project: netbeans   Source File: ExcludeDependencyPanel.java    License: 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();
    }
}