Java Code Examples for javax.swing.JSpinner#setEnabled()

The following examples show how to use javax.swing.JSpinner#setEnabled() . 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: AnimationObjectEditor.java    From CodenameOne with GNU General Public License v2.0 6 votes vote down vote up
private void initSourceDestMotion(Motion m, JSpinner start, JCheckBox check, JSpinner dest, JComboBox motionType) {
    if(m == null) {
        check.setSelected(false);
        start.setEnabled(false);
        dest.setEnabled(false);
        return;
    }
    start.setValue(m.getSourceValue());
    //if(m.getSourceValue() != m.getDestinationValue()) {
        check.setSelected(true);
        motionType.setEnabled(true);
        dest.setEnabled(true);
        start.setEnabled(true);
    //} else {
    //    check.setSelected(false);
    //}
    motionType.setSelectedIndex(AnimationAccessor.getMotionType(m) - 1);
    dest.setValue(m.getDestinationValue());
}
 
Example 2
Source File: PixelExtractionParametersForm.java    From snap-desktop with GNU General Public License v3.0 6 votes vote down vote up
private Component[] createTimeDeltaComponents(TableLayout tableLayout) {
    final JLabel boxLabel = new JLabel("Allowed time difference:");
    timeBox = new JCheckBox("Use time difference constraint");
    final Component horizontalSpacer = tableLayout.createHorizontalSpacer();

    final Component horizontalSpacer2 = tableLayout.createHorizontalSpacer();
    timeSpinner = new JSpinner(new SpinnerNumberModel(1, 1, null, 1));
    timeSpinner.setEnabled(false);
    timeUnitComboBox = new JComboBox<>(new String[]{"Day(s)", "Hour(s)", "Minute(s)"});
    timeUnitComboBox.setEnabled(false);

    timeBox.addActionListener(e -> {
        timeSpinner.setEnabled(timeBox.isSelected());
        timeUnitComboBox.setEnabled(timeBox.isSelected());
    });

    return new Component[]{boxLabel, timeBox, horizontalSpacer, horizontalSpacer2, timeSpinner, timeUnitComboBox};
}
 
Example 3
Source File: ComponentController.java    From swingsane with Apache License 2.0 5 votes vote down vote up
private void updateBlackThresholdModel(SpinnerModel blackThresholdSpinnerModel) {
  JSpinner blackThresholdSpinner = components.getBlackThresholdSpinner();
  blackThresholdSpinner.setModel(blackThresholdSpinnerModel != null ? blackThresholdSpinnerModel
      : new SpinnerNumberModel(1, 1, null, 1));
  blackThresholdSpinner.setEnabled(blackThresholdSpinnerModel != null ? !(components
      .getDefaultThresholdCheckBox().isSelected()) : false);
}
 
Example 4
Source File: ComponentController.java    From swingsane with Apache License 2.0 5 votes vote down vote up
private void updatePagesToScan(Integer pagesToScan) {
  JSpinner pagesToScanSpinner = components.getPagesToScanSpinner();
  if (pagesToScan == null) {
    pagesToScanSpinner.setEnabled(false);
  } else {
    pagesToScanSpinner.setEnabled(!(components.getBatchScanCheckBox().isSelected()));
    pagesToScanSpinner.setValue(pagesToScan);
  }
}
 
Example 5
Source File: ManualScriptPanel.java    From EchoSim with Apache License 2.0 5 votes vote down vote up
private void initInstantiate()
{
    mGenerate = new JButton("Generate Script");
    mExhaustive = new JCheckBox("All Possible Test Cases");
    mExhaustive.setSelected(true);
    mNumberOfTests = new JSpinner();
    mNumberOfTests.setEnabled(false);
    mRandomize = new JCheckBox("Randomize Order");
    mUseHistory = new JCheckBox("Use History");
    mUseHistory.setToolTipText("Use currently logged history to generate 'expected' results");
    mScript = new JTextPane();
    mScript.setContentType("text/html");
    mScript.setEditable(false);
}
 
Example 6
Source File: JPlagCreator.java    From jplag with GNU General Public License v3.0 5 votes vote down vote up
public static JSpinner createSpinner(int width, int height, String toolTip) {
	SpinnerNumberModel model = new SpinnerNumberModel(1, 1, 100, 1);
	JSpinner spinner = new JSpinner(model);
	spinner.setFont(JPlagCreator.SYSTEM_FONT);
	spinner.setPreferredSize(new java.awt.Dimension(width, height));
	spinner.setEnabled(true);
	spinner.setBackground(java.awt.Color.WHITE);
	if (toolTip != null && !toolTip.equals(""))
		((JSpinner.DefaultEditor) spinner.getEditor()).getTextField().setToolTipText(toolTip);
	return spinner;
}
 
Example 7
Source File: GUIFrame.java    From jaamsim with Apache License 2.0 5 votes vote down vote up
private void addSpeedMultiplier(JToolBar mainToolBar, Insets margin) {
	SpinnerNumberModel numberModel =
			new SpinnerModel(Simulation.DEFAULT_REAL_TIME_FACTOR,
			   Simulation.MIN_REAL_TIME_FACTOR, Simulation.MAX_REAL_TIME_FACTOR, 1);
	spinner = new JSpinner(numberModel);

	// show up to 6 decimal places
	JSpinner.NumberEditor numberEditor = new JSpinner.NumberEditor(spinner,"0.######");
	spinner.setEditor(numberEditor);

	// make sure spinner TextField is no wider than 9 digits
	int diff =
		((JSpinner.DefaultEditor)spinner.getEditor()).getTextField().getPreferredSize().width -
		getPixelWidthOfString_ForFont("9", spinner.getFont()) * 9;
	Dimension dim = spinner.getPreferredSize();
	dim.width -= diff;
	spinner.setPreferredSize(dim);
	spinner.addChangeListener(new ChangeListener() {

		@Override
		public void stateChanged( ChangeEvent e ) {
			Double val = (Double)((JSpinner)e.getSource()).getValue();
			if (MathUtils.near(val, sim.getSimulation().getRealTimeFactor()))
				return;
			NumberFormat nf = NumberFormat.getNumberInstance(Locale.US);
			DecimalFormat df = (DecimalFormat)nf;
			df.applyPattern("0.######");
			KeywordIndex kw = InputAgent.formatArgs("RealTimeFactor", df.format(val));
			InputAgent.storeAndExecute(new KeywordCommand(sim.getSimulation(), kw));
			controlStartResume.requestFocusInWindow();
		}
	});

	spinner.setToolTipText(formatToolTip("Speed Multiplier (&lt and &gt keys)",
			"Target ratio of simulation time to wall clock time when Real Time mode is selected."));
	spinner.setEnabled(false);
	mainToolBar.add( spinner );
}
 
Example 8
Source File: NeuriteTracerResultsDialog.java    From SNT with GNU General Public License v3.0 5 votes vote down vote up
private JPanel tracingPanel() {

		final JPanel tracingOptionsPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
		useSnapWindow = new JCheckBox("Enable cursor [s]napping within: XY", plugin.snapCursor);
		useSnapWindow.setBorder(new EmptyBorder(0, 0, 0, 0));
		useSnapWindow.addItemListener(this);
		tracingOptionsPanel.add(useSnapWindow);

		final SpinnerModel xy_model = new SpinnerNumberModel(plugin.cursorSnapWindowXY * 2,
				SimpleNeuriteTracer.MIN_SNAP_CURSOR_WINDOW_XY, SimpleNeuriteTracer.MAX_SNAP_CURSOR_WINDOW_XY * 2, 2);
		snapWindowXYsizeSpinner = new JSpinner(xy_model);
		((DefaultEditor) snapWindowXYsizeSpinner.getEditor()).getTextField().setEditable(false);
		snapWindowXYsizeSpinner.addChangeListener(this);
		tracingOptionsPanel.add(snapWindowXYsizeSpinner);

		final JLabel z_spinner_label = leftAlignedLabel("Z", isStackAvailable());
		z_spinner_label.setBorder(new EmptyBorder(0, 2, 0, 0));
		tracingOptionsPanel.add(z_spinner_label);
		final SpinnerModel z_model = new SpinnerNumberModel(plugin.cursorSnapWindowZ * 2,
				SimpleNeuriteTracer.MIN_SNAP_CURSOR_WINDOW_Z, SimpleNeuriteTracer.MAX_SNAP_CURSOR_WINDOW_Z * 2, 2);
		snapWindowZsizeSpinner = new JSpinner(z_model);
		((DefaultEditor) snapWindowZsizeSpinner.getEditor()).getTextField().setEditable(false);
		snapWindowZsizeSpinner.addChangeListener(this);
		snapWindowZsizeSpinner.setEnabled(isStackAvailable());
		tracingOptionsPanel.add(snapWindowZsizeSpinner);
		// tracingOptionsPanel.setBorder(new EmptyBorder(0, 0, 0, 0));
		return tracingOptionsPanel;
	}
 
Example 9
Source File: LimitRowsCheckBoxActionListener.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
public LimitRowsCheckBoxActionListener(final JSpinner maxPreviewRowsSpinner)
{
  this.maxPreviewRowsSpinner = maxPreviewRowsSpinner;
  putValue(Action.NAME, Messages.getString("QueryPanel.LimitRowsCheckBox"));
  putValue(Action.MNEMONIC_KEY, Messages.getMnemonic("QueryPanel.LimitRowsCheckBox.Mnemonic"));
  maxPreviewRowsSpinner.setEnabled(false);
}
 
Example 10
Source File: MapHeaderEditorPanel.java    From settlers-remake with MIT License 4 votes vote down vote up
private void generate(boolean sizeChangable) {
	nameField = new JTextField();
	descriptionField = new JTextArea(5, 40);
	descriptionField.setLineWrap(true);
	descriptionField.setWrapStyleWord(true);

	width = new SpinnerNumberModel(DEFAULT_MAPSIZE, MIN_MAPSIZE,
			MAX_MAPSIZE, 1);
	height = new SpinnerNumberModel(DEFAULT_MAPSIZE, MIN_MAPSIZE,
			MAX_MAPSIZE, 1);
	minPlayer = new SpinnerNumberModel(1, 1, CommonConstants.MAX_PLAYERS, 1);
	maxPlayer = new SpinnerNumberModel(1, 1, CommonConstants.MAX_PLAYERS, 1);

	JSpinner widthField = new JSpinner(width);
	JSpinner heightField = new JSpinner(height);
	JSpinner minPlayerField = new JSpinner(minPlayer);
	JSpinner maxPlayerField = new JSpinner(maxPlayer);

	JLabel nameLabel = new JLabel(EditorLabels.getLabel("header.map-name"));
	JLabel descriptionLabel = new JLabel(EditorLabels.getLabel("header.map-description"));
	JLabel widthLabel = new JLabel(EditorLabels.getLabel("header.width"));
	JLabel heightLabel = new JLabel(EditorLabels.getLabel("header.height"));
	JLabel minPlayerLabel = new JLabel(EditorLabels.getLabel("header.map-min-player"));
	JLabel maxPlayerLabel = new JLabel(EditorLabels.getLabel("header.map-max-player"));

	add(nameField);
	add(descriptionField);
	add(heightField);
	add(widthField);
	add(minPlayerField);
	add(maxPlayerField);

	add(nameLabel);
	add(descriptionLabel);
	add(widthLabel);
	add(heightLabel);
	add(maxPlayerLabel);
	add(minPlayerLabel);

	GroupLayout layout = new GroupLayout(this);
	setLayout(layout);
	layout.setAutoCreateGaps(true);
	layout.setAutoCreateContainerGaps(true);

	// @formatter:off
	layout.setHorizontalGroup(layout.createSequentialGroup()
			.addGroup(layout.createParallelGroup()
					.addComponent(nameLabel)
					.addComponent(descriptionLabel)
					.addComponent(heightLabel)
					.addComponent(widthLabel)
					.addComponent(maxPlayerLabel)
					.addComponent(minPlayerLabel))
			.addGroup(layout.createParallelGroup()
					.addComponent(nameField)
					.addComponent(descriptionField)
					.addComponent(heightField)
					.addComponent(widthField)
					.addComponent(maxPlayerField)
					.addComponent(minPlayerField)));
	layout.setVerticalGroup(layout.createSequentialGroup()
			.addGroup(layout.createParallelGroup()
					.addComponent(nameLabel)
					.addComponent(nameField))
			.addGroup(layout.createParallelGroup()
					.addComponent(descriptionLabel)
					.addComponent(descriptionField))
			.addGroup(layout.createParallelGroup()
					.addComponent(widthLabel)
					.addComponent(widthField))
			.addGroup(layout.createParallelGroup()
					.addComponent(heightLabel)
					.addComponent(heightField))
			.addGroup(layout.createParallelGroup()
					.addComponent(minPlayerLabel)
					.addComponent(minPlayerField))
			.addGroup(layout.createParallelGroup()
					.addComponent(maxPlayerLabel)
					.addComponent(maxPlayerField)));
	// @formatter:on

	if (!sizeChangable) {
		widthField.setEnabled(false);
		heightField.setEnabled(false);
	}
}
 
Example 11
Source File: ColorEditor.java    From jpexs-decompiler with GNU General Public License v3.0 4 votes vote down vote up
private static Color noTransparencyColorChooser(Component component, String title, Color initialColor) throws Exception {
    final JColorChooser pane = new JColorChooser(initialColor != null
            ? initialColor : Color.white);

    AbstractColorChooserPanel[] colorPanels = pane.getChooserPanels();
    for (int i = 1; i < colorPanels.length; i++) {
        AbstractColorChooserPanel cp = colorPanels[i];

        Field f = cp.getClass().getDeclaredField("panel");
        f.setAccessible(true);

        Object colorPanel = f.get(cp);
        Field f2 = colorPanel.getClass().getDeclaredField("spinners");
        f2.setAccessible(true);
        Object spinners = f2.get(colorPanel);

        Object transpSlispinner = Array.get(spinners, 3);
        if (i == colorPanels.length - 1) {
            transpSlispinner = Array.get(spinners, 4);
        }
        Field f3 = transpSlispinner.getClass().getDeclaredField("slider");
        f3.setAccessible(true);
        JSlider slider = (JSlider) f3.get(transpSlispinner);
        slider.setEnabled(false);
        Field f4 = transpSlispinner.getClass().getDeclaredField("spinner");
        f4.setAccessible(true);
        JSpinner spinner = (JSpinner) f4.get(transpSlispinner);
        spinner.setEnabled(false);
    }
    final Color[] col = new Color[]{initialColor};

    JDialog dialog = JColorChooser.createDialog(component, title, true, pane, new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            col[0] = pane.getColor();
        }
    }, null);

    dialog.setVisible(true);
    return col[0];

}
 
Example 12
Source File: StatisticsPanel.java    From snap-desktop with GNU General Public License v3.0 4 votes vote down vote up
private JPanel createAccuracyPanel() {
    final JPanel accuracyPanel = new JPanel(new GridBagLayout());
    final GridBagConstraints gbc = new GridBagConstraints();
    final JLabel label = new JLabel("Histogram accuracy:");

    accuracyModel = new AccuracyModel();
    final BindingContext bindingContext = new BindingContext(PropertyContainer.createObjectBacked(accuracyModel));
    final SpinnerNumberModel accuracyNumberModel = new SpinnerNumberModel(accuracyModel.accuracy, 0, Util.MAX_ACCURACY, 1);
    final JSpinner accuracySpinner = new JSpinner(accuracyNumberModel);
    ((JSpinner.DefaultEditor) accuracySpinner.getEditor()).getTextField().setEditable(false);
    bindingContext.bind("accuracy", accuracySpinner);
    final JCheckBox checkBox = new JCheckBox("Auto accuracy");
    bindingContext.bind("useAutoAccuracy", checkBox);

    final IntervalValidator rangeValidator = new IntervalValidator(new ValueRange(0, Util.MAX_ACCURACY));
    final PropertyDescriptor accuracyDescriptor = bindingContext.getPropertySet().getDescriptor("accuracy");
    accuracyDescriptor.setValidator(rangeValidator);

    checkBox.setSelected(accuracyModel.useAutoAccuracy);

    bindingContext.getPropertySet().getProperty("useAutoAccuracy").addPropertyChangeListener(new PropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            label.setEnabled(!checkBox.isSelected());
            accuracySpinner.setEnabled(!checkBox.isSelected());
            if (checkBox.isSelected()) {
                bindingContext.getBinding("accuracy").setPropertyValue(3);
            }
            computePanel.updateEnablement();
        }
    });

    label.setEnabled(false);
    accuracySpinner.setEnabled(false);
    accuracySpinner.setToolTipText("Specify the number of histogram bins (#bins: 10^accuracy).");
    accuracySpinner.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            computePanel.updateEnablement();
        }
    });

    GridBagUtils.addToPanel(accuracyPanel, new TitledSeparator("Histogram accuracy"), gbc, "fill=HORIZONTAL, weightx=1.0,anchor=NORTH,gridwidth=2");
    GridBagUtils.addToPanel(accuracyPanel, checkBox, gbc, "gridy=1,insets.left=5,insets.top=2");
    GridBagUtils.addToPanel(accuracyPanel, label, gbc, "gridy=2, insets.left=26,weightx=0.0,fill=NONE,anchor=WEST,gridwidth=1");
    GridBagUtils.addToPanel(accuracyPanel, accuracySpinner, gbc, "gridx=1,weightx=1.0,fill=HORIZONTAL,insets.right=5,insets.left=5");
    return accuracyPanel;
}