new JFormattedTextField(Formatter formatter) : JFormattedTextField « javax.swing « Java by API






new JFormattedTextField(Formatter formatter)

  
import java.awt.BorderLayout;
import java.text.ParseException;

import javax.swing.Box;
import javax.swing.JFormattedTextField;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.text.MaskFormatter;

public class MainClass {
  public static void main(String args[]) {
    JFrame f = new JFrame("JFormattedTextField Sample");
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Box rowOne = Box.createHorizontalBox();
    rowOne.add(new JLabel("SSN:"));
    try {
      MaskFormatter mf1 = new MaskFormatter("###-##-####");
      rowOne.add(new JFormattedTextField(mf1));
    } catch (ParseException e) {
    }
    f.add(rowOne, BorderLayout.NORTH);

    f.setSize(300, 100);
    f.setVisible(true);
  }
}
           
         
    
  








Related examples in the same category

1.new JFormattedTextField(Format format)
2.new JFormattedTextField(AbstractFormatterFactory factory, Object currentValue)
3.new JFormattedTextField(Object value)
4.new JFormattedTextField(new MaskFormatter('(###)###-####'))
5.new JFormattedTextField(new DecimalFormat('###,###'))
6.new JFormattedTextField(new SimpleDateFormat('MM/dd/yy'))
7.JFormattedTextField: addActionListener(ActionListener l)
8.JFormattedTextField: commitEdit()
9.JFormattedTextField: getFormatterFactory()
10.JFormattedTextField: getValue()
11.JFormattedTextField: isEditValid()
12.JFormattedTextField: setColumns(int columns)
13.JFormattedTextField: setFont(Font f)
14.JFormattedTextField: setFormatterFactory(AbstractFormatterFactory tf)
15.JFormattedTextField: setInputVerifier(InputVerifier inputVerifier)
16.JFormattedTextField: setValue(Object value)
17.JFormattedTextField deals with URL