Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Demo {
- public static void main(String[] args) throws Exception {
- JFrame frame = new JFrame();
- frame.setLayout(new FlowLayout());
- frame.setSize(300, 300);
- frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- MaskFormatter mask = new MaskFormatter("########/##");
- JFormattedTextField txtName = new JFormattedTextField();
- mask.install(txtName);
- frame.add(txtName);
- JButton button = new JButton("click me");
- button.addActionListener((e)-> {
- System.out.println(txtName.getText());
- });
- frame.add(button);
- frame.setVisible(true);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement