当前位置: 首页>>代码示例>>Java>>正文


Java JFormattedTextField.setEditable方法代码示例

本文整理汇总了Java中javax.swing.JFormattedTextField.setEditable方法的典型用法代码示例。如果您正苦于以下问题:Java JFormattedTextField.setEditable方法的具体用法?Java JFormattedTextField.setEditable怎么用?Java JFormattedTextField.setEditable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.JFormattedTextField的用法示例。


在下文中一共展示了JFormattedTextField.setEditable方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: IntegerEditor

import javax.swing.JFormattedTextField; //导入方法依赖的package包/类
/**
 * Construct a <code>JSpinner</code> editor that supports displaying and
 * editing the value of a <code>SpinnerIntModel</code> with a
 * <code>JFormattedTextField</code>. <code>This</code>
 * <code>IntegerEditor</code> becomes both a <code>ChangeListener</code>
 * on the spinner and a <code>PropertyChangeListener</code> on the new
 * <code>JFormattedTextField</code>.
 *
 * @param spinner the spinner whose model <code>this</code> editor will
 *            monitor
 * @param format the <code>NumberFormat</code> object that's used to
 *            display and parse the value of the text field.
 * @exception IllegalArgumentException if the spinners model is not an
 *                instance of <code>SpinnerIntModel</code>
 *
 * @see #getTextField
 * @see SpinnerIntModel
 * @see java.text.DecimalFormat
 */
private IntegerEditor(JSpinner spinner, NumberFormat format) {
	super(spinner);
	if (!(spinner.getModel() instanceof SpinnerIntModel)) {
		throw new IllegalArgumentException("model not a SpinnerIntModel");
	}

	format.setGroupingUsed(false);
	format.setMaximumFractionDigits(0);
	SpinnerIntModel model = (SpinnerIntModel) spinner.getModel();
	NumberFormatter formatter = new IntegerEditorFormatter(model, format);
	DefaultFormatterFactory factory = new DefaultFormatterFactory(formatter);
	JFormattedTextField ftf = getTextField();
	ftf.setEditable(true);
	ftf.setFormatterFactory(factory);
	ftf.setHorizontalAlignment(JTextField.RIGHT);

	try {
		String minString = formatter.valueToString(model.getMinimum());
		String maxString = formatter.valueToString(model.getMaximum());
		// Trying to approximate the width difference between "m" and "0" by multiplying with 0.7
		ftf.setColumns((int) Math.round(0.7 * Math.max(maxString.length(), minString.length())));
	} catch (ParseException e) {
		// Nothing to do, the component width will simply be the default
	}
}
 
开发者ID:DigitalMediaServer,项目名称:DigitalMediaServer,代码行数:45,代码来源:CustomJSpinner.java

示例2: HexaEditor

import javax.swing.JFormattedTextField; //导入方法依赖的package包/类
HexaEditor (JSpinner spinner)
{
    super(spinner);

    JFormattedTextField ftf = getTextField();
    ftf.setEditable(true);
    ftf.setFormatterFactory(new HexaFormatterFactory());
}
 
开发者ID:Audiveris,项目名称:audiveris,代码行数:9,代码来源:LHexaSpinner.java

示例3: PgTimeSpinner

import javax.swing.JFormattedTextField; //导入方法依赖的package包/类
/** Create a new page time spinner */
public PgTimeSpinner() {
	setModel(new PgTimeSpinnerModel(
		PageTimeHelper.defaultPageOnInterval().seconds(),
		PageTimeHelper.minPageOnInterval(), INC_ONTIME_SECS));
	setToolTipText(I18N.get("dms.page.on.time.tooltip"));

	// force the spinner to be editable
	JFormattedTextField tf = ((JSpinner.DefaultEditor)
		this.getEditor()).getTextField();
   		tf.setEditable(true);
}
 
开发者ID:CA-IRIS,项目名称:ca-iris,代码行数:13,代码来源:PgTimeSpinner.java

示例4: SoftSphereSolidEOSCalculator

import javax.swing.JFormattedTextField; //导入方法依赖的package包/类
public SoftSphereSolidEOSCalculator() {
		super(new BorderLayout());
		
		double density = 1.1964;
		double temperature = 1.0;
		double[] quantity = getAllQuantity(FCC, n, temperature, density);
		
		//Create the labels.
		densityLabel = new JLabel(densityString);
		temperatureLabel = new JLabel(temperatureString);
		bALabel = new JLabel(bAString);
		ZLabel = new JLabel(ZString);
		bULabel = new JLabel(bUString);
		
		//Create the text fields and set them up.
		densityField = new JFormattedTextField(densityFormat);
		densityField.setValue(new Double(density));
		densityField.setColumns(10);
		densityField.addPropertyChangeListener("value", this);
		
		temperatureField = new JFormattedTextField(temperatureFormat);
		temperatureField.setValue(new Double(temperature));
		temperatureField.setColumns(10);
		temperatureField.addPropertyChangeListener("value", this);
		
		bAField = new JFormattedTextField(bAFormat);
		bAField.setValue(new Double(quantity[0]));
		bAField.setColumns(10);
		bAField.setEditable(false);
//		paymentField.setForeground(Color.red);
		
		ZField = new JFormattedTextField(ZFormat);
		ZField.setValue(new Double(quantity[1]));
		ZField.setColumns(10);
		ZField.setEditable(false);
		
		bUField = new JFormattedTextField(bUFormat);
		bUField.setValue(new Double(quantity[2]));
		bUField.setColumns(10);
		bUField.setEditable(false);
		
		//Tell accessibility tools about label/textfield pairs.
		densityLabel.setLabelFor(densityField);
		temperatureLabel.setLabelFor(temperatureField);
		bALabel.setLabelFor(bAField);
		ZLabel.setLabelFor(ZField);
		bULabel.setLabelFor(bUField);
		
		//Lay out the labels in a panel.
		JPanel labelPane = new JPanel(new GridLayout(0,1));
		labelPane.add(densityLabel);
		labelPane.add(temperatureLabel);
		labelPane.add(bALabel);
		labelPane.add(ZLabel);
		labelPane.add(bULabel);
		
		//Layout the text fields in a panel.
		JPanel fieldPane = new JPanel(new GridLayout(0,1));
		fieldPane.add(densityField);
		fieldPane.add(temperatureField);
		fieldPane.add(bAField);
		fieldPane.add(ZField);
		fieldPane.add(bUField);
		
		//Put the panels in this panel, labels on left,
		//text fields on right.
		setBorder(BorderFactory.createEmptyBorder(40, 40, 40, 40));
		add(labelPane, BorderLayout.CENTER);
		add(fieldPane, BorderLayout.LINE_END);
		

//		LayoutStyle layout = new 
	}
 
开发者ID:etomica,项目名称:etomica,代码行数:74,代码来源:SoftSphereSolidEOSCalculator.java


注:本文中的javax.swing.JFormattedTextField.setEditable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。