Java 8 JFormattedTextField - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 JFormattedTextField class.

This code example shows how to use the following methods:addPropertyChangeListener, setColumns
6
CodeRank
This code example shows how to use the following methods:addPropertyChangeListener, setValue, setColumns
	public Initiative initiative;
 
	private javax.swing.JComboBox typeCombo;
 
	private javax.swing.JLabel nameLabel;
	private javax.swing.JLabel conLabel;
	private javax.swing.JLabel intLabel;
	private javax.swing.JLabel wisLabel;
	private javax.swing.JLabel chaLabel;
	private javax.swing.JLabel fortLabel;
	private javax.swing.JLabel reflexLabel;
	private javax.swing.JLabel willLabel;
	private javax.swing.JLabel crLabel;
	private javax.swing.JLabel noteLabel;
	private javax.swing.JLabel playerLabel;
	private javax.swing.JLabel bonusLabel;
	private javax.swing.JLabel numberLabel;
	private javax.swing.JLabel neg20Label;
	private javax.swing.JLabel neg20Label2;
	private javax.swing.JLabel hpLabel;

5
CodeRank
This code example shows how to use the following methods:addMouseListener, setComponentPopupMenu, setValue
        customizeComponents(); 
    } 
     
    private void customizeComponents(){ 
         
        sizeTextField.setComponentPopupMenu(rightClickMenu);
        ActionListener actList = new ActionListener(){
            @Override 
            public void actionPerformed(ActionEvent e){
                JMenuItem jmi = (JMenuItem) e.getSource();
                if(jmi.equals(cutMenuItem))
                    sizeTextField.cut();
                else if(jmi.equals(copyMenuItem))
                    sizeTextField.copy();
                else if(jmi.equals(pasteMenuItem))
                    sizeTextField.paste();
                else if(jmi.equals(selectAllMenuItem))
                    sizeTextField.selectAll();
            } 
        }; 

5
CodeRank
This code example shows how to use the following methods:commitEdit, isEditValid, postActionEvent
		{ 
 
			@Override 
			public void actionPerformed(ActionEvent e)
			{ 
				if (!ftf.isEditValid())
				{ //The text is invalid. 
					if (userSaysRevert()) 
					{ //reverted 
						ftf.postActionEvent(); //inform the editor
					} 
				} 
				else 
				{ 
					try 
					{              //The text is valid, 
						ftf.commitEdit();     //so use it.
						ftf.postActionEvent(); //stop editing
					} 
					catch (java.text.ParseException exc)

5
CodeRank
This code example shows how to use the following methods:setPreferredSize, setValue, setEditable
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBox1ActionPerformed(evt);
            } 
        }); 
 
        jFormattedTextField1.setPreferredSize(new java.awt.Dimension(40, 20));
 
        jFormattedTextField2.setPreferredSize(new java.awt.Dimension(40, 20));
 
        java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("org/yccheok/jstock/data/gui"); // NOI18N
        jLabel2.setText(bundle.getString("SplitJDialog_Unit")); // NOI18N
 
        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

5
CodeRank
This code example shows how to use the following methods:
		 
		String formatValue = (String) typeDefinition.get(FORMAT);
		@SuppressWarnings("unused") 
		String localeValue = (String)typeDefinition.get(FORMAT_LOCALE);
		if (formatValue == null) {
			instance = new JFormattedTextField();
		} else { 
			@SuppressWarnings("unused") 
			Format format = null;
			if (FORMAT_VALUE_DATE.equals(formatValue)) {
				Integer style = (Integer) typeDefinition.get(FORMAT_STYLE);
				if (style == null) {
					format = DateFormat.getDateInstance();
				} else { 
					format = DateFormat.getDateInstance(style);
				} 
			} else if (FORMAT_VALUE_TIME.equals(formatValue)) {
				Integer style = (Integer) typeDefinition.get(FORMAT_STYLE);
				if (style == null) {
					format = DateFormat.getTimeInstance();

5
CodeRank
This code example shows how to use the following methods:getValue, setValue
 
	@Override 
	public void referenceChanged(ReferenceEvent<BigDecimal> e)
	{ 
		BigDecimal newVal = e.getNewReference();
		BigDecimal oldVal = new BigDecimal(((Number) field.getValue()).doubleValue());
		if (oldVal.compareTo(newVal) != 0)
		{ 
			field.setValue(newVal);
		} 
	} 
 
	protected abstract void valueChanged(BigDecimal value);
 
	@Override 
	public void propertyChange(PropertyChangeEvent evt)
	{ 
		valueChanged(new BigDecimal(((Number) field.getValue()).doubleValue()));
	} 
 
5
CodeRank
This code example shows how to use the following methods:addKeyListener, setHorizontalAlignment
 
public class FieldFactory { 
	 
	public static JFormattedTextField createIntegerField(int minValue, int maxLength) {
		IntegerFormatter formatter = new IntegerFormatter(minValue);
		JFormattedTextField field = new JFormattedTextField(formatter);
		field.setHorizontalAlignment(JTextField.CENTER);
		field.addKeyListener(new FieldListener(maxLength));
		return field;
	} 
	 
	@SuppressWarnings("serial") 
	private static class IntegerFormatter extends AbstractFormatter {
		 
		private final int minValue;
		private final NumberFormatter numberFormatter;
 
		public IntegerFormatter(int minValue) {
			this.minValue = minValue;
			numberFormatter = new NumberFormatter(NumberFormat.getIntegerInstance());
4
CodeRank
This code example shows how to use the following methods:getValue, setValue
 
	@Override 
	public void referenceChanged(ReferenceEvent<Integer> e)
	{ 
		int newVal = e.getNewReference();
		int oldVal = ((Number) field.getValue()).intValue();
		if (oldVal != newVal)
		{ 
			field.setValue(newVal);
		} 
	} 
 
	protected abstract void valueChanged(int value);
 
	@Override 
	public void propertyChange(PropertyChangeEvent evt)
	{ 
		valueChanged(((Number) field.getValue()).intValue());
	} 
 
5
CodeRank
This code example shows how to use the following methods:addKeyListener, setHorizontalAlignment
import org.tomighty.config.Options; 
import org.tomighty.i18n.Messages; 
import org.tomighty.ui.util.FieldFactory; 
 
@SuppressWarnings("serial") 
public class Times extends OptionPanel implements OptionGroup { 
 
	@Inject private Options options;
	@Inject private Messages messages;
 
	private JFormattedTextField pomodoro;
	private JFormattedTextField shortBreak;
	private JFormattedTextField longBreak;
 
    @PostConstruct 
	public void initialize() { 
		pomodoro = addField("Pomodoro");
		shortBreak = addField("Short break");
		longBreak = addField("Long break");
	} 
4
CodeRank
See Code Examples for Java 8 JFormattedTextField Methods: