Java Utililty Methods JTextField

List of utility methods to do JTextField

Description

The list of methods to do JTextField are organized into topic(s).

Method

voidponerMayuscula(KeyEvent e, JTextField textField)
poner Mayuscula
char keyChar = e.getKeyChar();
if (Character.isLetter(keyChar))
    textField.setText(textField.getText().trim().toUpperCase());
voidquickButtonFlip(JTextField t, JTextField a, JTextField b)
Toggles the editiablity of our text fields.
t.setEditable(true);
a.setEditable(false);
b.setEditable(false);
BufferedImagereadBufferedImage(JTextField out)
Reads an image file from disk and returns and BufferedImage.
BufferedImage image = null;
File fileLocation = new File("img/balls.gif");
try {
    image = ImageIO.read(fileLocation);
} catch (IOException e) {
    out.setText(String.format("Could not open image: %s", "img/balls.gif"));
return image;
...
voidsecureTextDeletionFromTextField(JTextField textField, int length)
Deletes text from JTextField s in a secure way.
byte[] bytes = new byte[length];
new SecureRandom().engineNextBytes(bytes);
String str = new String(bytes, 0, length);
textField.setText(str);
textField.setText(EMPTY_STRING);
voidsetEnabled(JTextField textField, boolean b)
set Enabled
textField.setEditable(b);
textField.setEnabled(b);
voidsetEnabled(JTextField textField, boolean enabled)
Method to enable/disable a Swing JTextField object
if (enabled) {
    textField.setEnabled(true);
    textField.setBackground(Color.WHITE);
} else {
    textField.setEnabled(false);
    textField.setBackground(UIManager.getColor("Panel.background"));
voidsetModelValue(JTextField tf, String value)
set Model Value
if (value != null) {
    tf.setText(value);
voidsetText(JTextField jField, Object pObject, Object pDefault)
set Text
if (jField == null) {
    return;
if (pObject != null) {
    jField.setText(pObject.toString());
} else {
    if (pDefault != null) {
        jField.setText(pDefault.toString());
...
voidsetupNoCommitCheckbox(final JCheckBox addLogInformationCheckBox, final JTextField commitMessage, final JCheckBox noCommitCheckBox)
Initialize no commit checkbox (for both merge and pull dialog)
noCommitCheckBox.addActionListener(new ActionListener() {
    public void actionPerformed(final ActionEvent e) {
        final boolean selected = noCommitCheckBox.isSelected();
        if (commitMessage != null) {
            commitMessage.setEnabled(!selected);
        if (selected) {
            addLogInformationCheckBox.setSelected(false);
...
voidsetupTextField(JPanel panel, JLabel label, JTextField field, long val, String toolTip)
setup Text Field
setupTextField(panel, label, field, _decimalFormat.format(val), toolTip);