Java Code Examples for javax.swing.JFormattedTextField#setColumns()

The following examples show how to use javax.swing.JFormattedTextField#setColumns() . 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: DateCellEditor.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Constructs a new <code>DatePickerParameterComponent</code>.
 */
public DateCellEditor( final Class dateType ) {
  this.listeners = new EventListenerList();
  this.dateType = dateType;
  if ( this.dateType.isArray() ) {
    this.dateType = this.dateType.getComponentType();
  }

  setLayout( new BorderLayout() );
  dateField = new JFormattedTextField();
  dateField.setColumns( 20 );
  dateField.setEditable( true );

  pickDateButton = new EllipsisButton( new PickDateListener() );

  add( dateField, BorderLayout.CENTER );
  add( pickDateButton, BorderLayout.EAST );
}
 
Example 2
Source File: GridSizeDialog.java    From Carcassonne with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Creates a dialog to change the grid size.
 * @param settings are the {@link GameSettings} that will receive the new grid size.
 */
public GridSizeDialog(GameSettings settings) {
    this.settings = settings;
    widthInput = new JFormattedTextField(createNumberFormatter());
    widthInput.setColumns(TEXT_FIELD_COLUMNS);
    heightInput = new JFormattedTextField(createNumberFormatter());
    heightInput.setColumns(TEXT_FIELD_COLUMNS);
    setLayout(new BorderLayout());
    add(new JLabel(MESSAGE), BorderLayout.NORTH);
    JPanel subPanel = new JPanel();
    subPanel.add(new JLabel(WIDTH));
    subPanel.add(widthInput);
    subPanel.add(Box.createHorizontalStrut(SPACE)); // a spacer
    subPanel.add(new JLabel(HEIGHT));
    subPanel.add(heightInput);
    add(subPanel, BorderLayout.SOUTH);

}
 
Example 3
Source File: SpinnerRangeDouble.java    From DeconvolutionLab2 with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Constructor.
 */
public SpinnerRangeDouble(double defValue, double minValue, double maxValue, double incValue, String format) {
	super();
	this.defValue = defValue;
	this.minValue = minValue;
	this.maxValue = maxValue;
	this.incValue = incValue;

	Double def = new Double(defValue);
	Double min = new Double(minValue);
	Double max = new Double(maxValue);
	Double inc = new Double(incValue);
	model = new SpinnerNumberModel(def, min, max, inc);
	setModel(model);
	setEditor(new JSpinner.NumberEditor(this, format));
	JFormattedTextField tf = ((JSpinner.DefaultEditor) getEditor()).getTextField();
	tf.setColumns(7);
}
 
Example 4
Source File: SpinnerRangeDouble.java    From DeconvolutionLab2 with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Constructor.
 */
public SpinnerRangeDouble(double defValue, double minValue, double maxValue, double incValue, int visibleChars) {
	super();
	this.defValue = defValue;
	this.minValue = minValue;
	this.maxValue = maxValue;
	this.incValue = incValue;

	Double def = new Double(defValue);
	Double min = new Double(minValue);
	Double max = new Double(maxValue);
	Double inc = new Double(incValue);
	model = new SpinnerNumberModel(def, min, max, inc);
	setModel(model);
	JFormattedTextField tf = ((JSpinner.DefaultEditor) getEditor()).getTextField();
	tf.setColumns(visibleChars);
}
 
Example 5
Source File: SpinnerRangeFloat.java    From DeconvolutionLab2 with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Constructor.
 */
public SpinnerRangeFloat(float defValue, float minValue, float maxValue, float incValue) {
	super();
	this.defValue = defValue;
	this.minValue = minValue;
	this.maxValue = maxValue;
	this.incValue = incValue;

	Float def = new Float(defValue);
	Float min = new Float(minValue);
	Float max = new Float(maxValue);
	Float inc = new Float(incValue);
	model = new SpinnerNumberModel(def, min, max, inc);
	setModel(model);
	JFormattedTextField tf = ((JSpinner.DefaultEditor) getEditor()).getTextField();
	tf.setColumns(7);
}
 
Example 6
Source File: SpinnerRangeFloat.java    From DeconvolutionLab2 with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Constructor.
 */
public SpinnerRangeFloat(float defValue, float minValue, float maxValue, float incValue, String format) {
	super();
	this.defValue = defValue;
	this.minValue = minValue;
	this.maxValue = maxValue;
	this.incValue = incValue;

	Double def = new Double(defValue);
	Double min = new Double(minValue);
	Double max = new Double(maxValue);
	Double inc = new Double(incValue);
	this.model = new SpinnerNumberModel(def, min, max, inc);
	setModel(model);
	setEditor(new JSpinner.NumberEditor(this, format));
	JFormattedTextField tf = ((JSpinner.DefaultEditor) getEditor()).getTextField();
	tf.setColumns(7);
}
 
Example 7
Source File: SpinnerRangeFloat.java    From DeconvolutionLab2 with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Constructor.
 */
public SpinnerRangeFloat(float defValue, float minValue, float maxValue, float incValue, int visibleChars) {
	super();
	this.defValue = defValue;
	this.minValue = minValue;
	this.maxValue = maxValue;
	this.incValue = incValue;

	Float def = new Float(defValue);
	Float min = new Float(minValue);
	Float max = new Float(maxValue);
	Float inc = new Float(incValue);
	model = new SpinnerNumberModel(def, min, max, inc);
	setModel(model);
	JFormattedTextField tf = ((JSpinner.DefaultEditor) getEditor()).getTextField();
	tf.setColumns(visibleChars);
}
 
Example 8
Source File: ValueFormatter.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
static void init(int length, boolean hex, JFormattedTextField text) {
    ValueFormatter formatter = new ValueFormatter(length, hex);
    text.setColumns(length);
    text.setFormatterFactory(new DefaultFormatterFactory(formatter));
    text.setHorizontalAlignment(SwingConstants.RIGHT);
    text.setMinimumSize(text.getPreferredSize());
    text.addFocusListener(formatter);
}
 
Example 9
Source File: ValueFormatter.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
static void init(int length, boolean hex, JFormattedTextField text) {
    ValueFormatter formatter = new ValueFormatter(length, hex);
    text.setColumns(length);
    text.setFormatterFactory(new DefaultFormatterFactory(formatter));
    text.setHorizontalAlignment(SwingConstants.RIGHT);
    text.setMinimumSize(text.getPreferredSize());
    text.addFocusListener(formatter);
}
 
Example 10
Source File: ValueFormatter.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
static void init(int length, boolean hex, JFormattedTextField text) {
    ValueFormatter formatter = new ValueFormatter(length, hex);
    text.setColumns(length);
    text.setFormatterFactory(new DefaultFormatterFactory(formatter));
    text.setHorizontalAlignment(SwingConstants.RIGHT);
    text.setMinimumSize(text.getPreferredSize());
    text.addFocusListener(formatter);
}
 
Example 11
Source File: SingleIntegerFieldOptionsPanel.java    From consulo with Apache License 2.0 5 votes vote down vote up
public static JFormattedTextField createIntegerFieldTrackingValue(@Nonnull InspectionProfileEntry owner,
                                                                  @Nonnull String property,
                                                                  int integerFieldColumns) {
    JFormattedTextField valueField = new JFormattedTextField();
    valueField.setColumns(integerFieldColumns);
    setupIntegerFieldTrackingValue(valueField, owner, property);
    return valueField;
}
 
Example 12
Source File: ImageInfoEditor.java    From snap-desktop with GNU General Public License v3.0 5 votes vote down vote up
private void editSliderSample(MouseEvent evt, final int sliderIndex) {
    final PropertyContainer vc = new PropertyContainer();
    vc.addProperty(Property.create("sample", getSliderSample(sliderIndex)));
    vc.getDescriptor("sample").setDisplayName("sample");
    vc.getDescriptor("sample").setUnit(getModel().getParameterUnit());
    final ValueRange valueRange;
    if (sliderIndex == 0) {
        valueRange = new ValueRange(Double.NEGATIVE_INFINITY, round(getMaxSliderSample(sliderIndex)));
    } else if (sliderIndex == getSliderCount() - 1) {
        valueRange = new ValueRange(round(getMinSliderSample(sliderIndex)), Double.POSITIVE_INFINITY);
    } else {
        valueRange = new ValueRange(round(getMinSliderSample(sliderIndex)), round(getMaxSliderSample(sliderIndex)));
    }
    vc.getDescriptor("sample").setValueRange(valueRange);

    final BindingContext ctx = new BindingContext(vc);
    final NumberFormatter formatter = new NumberFormatter(new DecimalFormat("#0.0#"));
    formatter.setValueClass(Double.class); // to ensure that double values are returned
    final JFormattedTextField field = new JFormattedTextField(formatter);
    field.setColumns(11);
    field.setHorizontalAlignment(JFormattedTextField.RIGHT);
    ctx.bind("sample", field);

    showPopup(evt, field);

    ctx.addPropertyChangeListener("sample", pce -> {
        hidePopup();
        setSliderSample(sliderIndex, (Double) ctx.getBinding("sample").getPropertyValue());
        computeZoomInToSliderLimits();
        applyChanges();
    });
}
 
Example 13
Source File: ValueFormatter.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
static void init(int length, boolean hex, JFormattedTextField text) {
    ValueFormatter formatter = new ValueFormatter(length, hex);
    text.setColumns(length);
    text.setFormatterFactory(new DefaultFormatterFactory(formatter));
    text.setHorizontalAlignment(SwingConstants.RIGHT);
    text.setMinimumSize(text.getPreferredSize());
    text.addFocusListener(formatter);
}
 
Example 14
Source File: ValueFormatter.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
static void init(int length, boolean hex, JFormattedTextField text) {
    ValueFormatter formatter = new ValueFormatter(length, hex);
    text.setColumns(length);
    text.setFormatterFactory(new DefaultFormatterFactory(formatter));
    text.setHorizontalAlignment(SwingConstants.RIGHT);
    text.setMinimumSize(text.getPreferredSize());
    text.addFocusListener(formatter);
}
 
Example 15
Source File: ValueFormatter.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
static void init(int length, boolean hex, JFormattedTextField text) {
    ValueFormatter formatter = new ValueFormatter(length, hex);
    text.setColumns(length);
    text.setFormatterFactory(new DefaultFormatterFactory(formatter));
    text.setHorizontalAlignment(SwingConstants.RIGHT);
    text.setMinimumSize(text.getPreferredSize());
    text.addFocusListener(formatter);
}
 
Example 16
Source File: ValueFormatter.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
static void init(int length, boolean hex, JFormattedTextField text) {
    ValueFormatter formatter = new ValueFormatter(length, hex);
    text.setColumns(length);
    text.setFormatterFactory(new DefaultFormatterFactory(formatter));
    text.setHorizontalAlignment(SwingConstants.RIGHT);
    text.setMinimumSize(text.getPreferredSize());
    text.addFocusListener(formatter);
}
 
Example 17
Source File: ValueFormatter.java    From Java8CN with Apache License 2.0 5 votes vote down vote up
static void init(int length, boolean hex, JFormattedTextField text) {
    ValueFormatter formatter = new ValueFormatter(length, hex);
    text.setColumns(length);
    text.setFormatterFactory(new DefaultFormatterFactory(formatter));
    text.setHorizontalAlignment(SwingConstants.RIGHT);
    text.setMinimumSize(text.getPreferredSize());
    text.addFocusListener(formatter);
}
 
Example 18
Source File: ValueFormatter.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
static void init(int length, boolean hex, JFormattedTextField text) {
    ValueFormatter formatter = new ValueFormatter(length, hex);
    text.setColumns(length);
    text.setFormatterFactory(new DefaultFormatterFactory(formatter));
    text.setHorizontalAlignment(SwingConstants.RIGHT);
    text.setMinimumSize(text.getPreferredSize());
    text.addFocusListener(formatter);
}
 
Example 19
Source File: CustomClientResizingProfilePanel.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
private JSpinner createSpinner(int value)
{
	SpinnerModel model = new SpinnerNumberModel(value, Integer.MIN_VALUE, Integer.MAX_VALUE, 1);
	JSpinner spinner = new JSpinner(model);
	Component editor = spinner.getEditor();
	JFormattedTextField spinnerTextField = ((JSpinner.DefaultEditor) editor).getTextField();
	spinnerTextField.setColumns(4);

	return spinner;
}
 
Example 20
Source File: ControlPanel.java    From openvisualtraceroute with GNU Lesser General Public License v3.0 4 votes vote down vote up
public SnifferControl() {
	super();
	setLayout(new FlowLayout(FlowLayout.LEFT, 2, 0));
	_hostIpTextField = new JTextField(17);
	_hostIpTextField.setText(Resources.getLabel("sniffer.host.tooltip"));
	final FirstInputListener listener = new FirstInputListener(_hostIpTextField);
	_hostIpTextField.addMouseListener(listener);
	_hostIpTextField.addKeyListener(listener);
	_hostIpTextField.setToolTipText(Resources.getLabel("sniffer.host.tooltip"));
	add(_hostIpTextField);

	final JLabel protocolLabel = new JLabel(Resources.getLabel("protocol.label"));
	protocolLabel.setToolTipText(Resources.getLabel("protocol.desc"));
	add(protocolLabel);
	for (final Protocol type : Protocol.values()) {
		if (type == Protocol.OTHER) {
			continue;
		}
		final JCheckBox check = new JCheckBox(type.name(), type == Protocol.TCP);
		_packets.put(type, check);
		add(check);
	}
	final JLabel portLabel = new JLabel(Resources.getLabel("port.label"));
	portLabel.setToolTipText(Resources.getLabel("port.desc"));
	_allPortCheck = new JCheckBox(Resources.getLabel("all.port.label"));
	_allPortCheck.setToolTipText(Resources.getLabel("all.port.desc"));
	_allPortCheck.setSelected(false);
	add(_allPortCheck);

	_portTF = new JFormattedTextField();
	_portTF.setText("80,443");
	_portTF.setColumns(15);
	//			_portTF.setMaximumSize(new Dimension(30, _portTF.getPreferredSize().height));
	add(portLabel);
	add(_portTF);
	_portTF.setEnabled(true);

	_allPortCheck.addChangeListener(e -> _portTF.setEnabled(!_allPortCheck.isSelected()));

	_filterPacketLengthCheck = new JCheckBox(Resources.getLabel("filter.length"));
	_filterPacketLengthCheck.setToolTipText(Resources.getLabel("filter.length.desc"));
	_filterPacketLengthCheck.setSelected(false);
	add(_filterPacketLengthCheck);

	_filterLengthTF = new JFormattedTextField(new NumberFormatterFactory());
	_filterLengthTF.setText("128");
	_filterLengthTF.setColumns(5);
	add(_filterLengthTF);

	_filterPacketLengthCheck.addChangeListener(e -> _filterLengthTF.setEnabled(_filterPacketLengthCheck.isEnabled() && _filterPacketLengthCheck.isSelected()));
	_capturePeriod = new JFormattedTextField(new NumberFormatterFactory());
	_capturePeriod.setText("0");
	_capturePeriod.setColumns(5);
	add(new JLabel(Resources.getLabel("capture.period")));
	add(_capturePeriod);

	_captureButton = new JButton(GO_IMG);
	_captureButton.setToolTipText(Resources.getLabel("capture.packet.start"));
	add(_captureButton);
	_captureButton.addActionListener(arg0 -> start());
}