Accepting Formatted Input : Formatted TextField « Swing JFC « Java






Accepting Formatted Input

Accepting Formatted Input
   
import java.awt.BorderLayout;
import java.awt.Container;
import java.util.Date;

import javax.swing.JFormattedTextField;
import javax.swing.JFrame;

public class FormattedTest {
  public static void main(String args[]) {
    JFrame frame = new JFrame("Formatted");
    Container contentPane = frame.getContentPane();
    JFormattedTextField ftf1 = new JFormattedTextField(new Integer(0));
    contentPane.add(ftf1, BorderLayout.NORTH);
    JFormattedTextField ftf2 = new JFormattedTextField(new Date());
    contentPane.add(ftf2, BorderLayout.SOUTH);
    frame.setSize(200, 100);
    frame.show();
  }
}
           
         
    
    
  








Related examples in the same category

1.different configurations of JFormattedTextField: Numberdifferent configurations of JFormattedTextField: Number
2.Different configurations of JFormattedTextField: DateDifferent configurations of JFormattedTextField: Date
3.JFormattedTextField: an input mask (###) ###-#### for a telephone number
4.Using an InputVerifier with a formatted textfieldUsing an InputVerifier with a formatted textfield
5.A formatter for regular expressions to be used with JFormattedTextFieldA formatter for regular expressions to be used with JFormattedTextField
6.Field with different formats with focus and withoutField with different formats with focus and without
7.Input: any number of hyphen-delimeted numbers. Output: int arrayInput: any number of hyphen-delimeted numbers. Output: int array
8.A quick demonstration of JFormattedTextFieldA quick demonstration of JFormattedTextField
9.Formatter Factory DemoFormatter Factory Demo
10.Formatted TextField DemoFormatted TextField Demo
11.Formatted TextField ExampleFormatted TextField Example
12.Input Verification Demo Input Verification Demo
13.Creating a Text Field to Display and Edit a Phone Number
14.Creating a Text Field to Display and Edit a social security number
15.Make custom Input Text Formatter in Java
16.Support a date with the custom format: 2009-1-1
17.A BigDecimal object custom formatter
18.A decimal number with one digit following the decimal point;
19.Dynamically change the format
20.Creating a Text Field to Display and Edit a Number
21.Creating a Text Field to Display and Edit a Date
22.Format and validate input field in Java Swing
23.Input Verification Dialog Demo Input Verification Dialog Demo
24.A collection of formatted text fields and a button that displays the field values.