Advertisement
Guest User

Untitled

a guest
Aug 14th, 2015
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.58 KB | None | 0 0
  1. class Demo {
  2.     public static void main(String[] args) throws Exception {
  3.         JFrame frame = new JFrame();
  4.         frame.setLayout(new FlowLayout());
  5.         frame.setSize(300, 300);
  6.         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  7.        
  8.  
  9.         MaskFormatter mask = new MaskFormatter("########/##");
  10.         JFormattedTextField txtName = new JFormattedTextField();
  11.         mask.install(txtName);
  12.        
  13.         frame.add(txtName);
  14.        
  15.         JButton button = new JButton("click me");
  16.         button.addActionListener((e)-> {
  17.             System.out.println(txtName.getText());
  18.         });
  19.         frame.add(button);
  20.         frame.setVisible(true);
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement