Java JTextField dateCompleteOnlyFormat(JTextField pJTextField, KeyEvent e)

Here you can find the source of dateCompleteOnlyFormat(JTextField pJTextField, KeyEvent e)

Description

date Complete Only Format

License

Open Source License

Declaration

public static void dateCompleteOnlyFormat(JTextField pJTextField,
            KeyEvent e) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import javax.swing.*;

import java.awt.event.KeyEvent;

public class Main {
    public static void dateCompleteOnlyFormat(JTextField pJTextField,
            KeyEvent e) {/*from www.j  av a 2  s .c o m*/
        char keyChar = e.getKeyChar();
        if (Character.isDigit(keyChar)) {
            if ((pJTextField.getText().trim().length() == 2)
                    || (pJTextField.getText().trim().length() == 5))
                pJTextField.setText(pJTextField.getText().trim() + "/");
        }
    }
}

Related

  1. checkJTextFieldNotEmpty(javax.swing.JTextField field, javax.swing.JLabel promptName, ArrayList errors)
  2. cleanTextFields(JTextField... textFields)
  3. createBrowseButton(final JTextField txtInput, final Window parent, final boolean directoryBrowser)
  4. createFieldWithLabel(String label, JTextField textField)
  5. createOutputPanel(JLabel outputFileNameLabel, JButton chooseOutputFileButton, JTextField outputFileTextField, String borderTitle)
  6. doAction(JTextField textField)
  7. fieldSetErrorVisual(final JTextField field)
  8. implyDisabled(final JCheckBox checked, final boolean checkedState, final JTextField changed)
  9. isActiveComponents(JTextField... textFields)