Java JTextField Create createJTextField(String name, int value, FocusListener fl)

Here you can find the source of createJTextField(String name, int value, FocusListener fl)

Description

Creates a new JTextField with the given name, integer value and adds a FocusListener.

License

Open Source License

Parameter

Parameter Description
name JTextField name.
value JTextField value.
fl FocusListener for this object's events

Return

The newly formed JTextField.

Declaration

public static JTextField createJTextField(String name, int value, FocusListener fl) 

Method Source Code

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

import java.awt.event.FocusListener;

import javax.swing.JTextField;

public class Main {
    /**//from  ww w .  j  ava 2 s. co m
     * Creates a new JTextField with the given name, integer value and adds
     * a FocusListener.
     * @param name JTextField name.
     * @param value JTextField value.
     * @param fl FocusListener for this object's events
     * @return The newly formed JTextField.
     */
    public static JTextField createJTextField(String name, int value, FocusListener fl) {

        JTextField jt = _createJTextField(name, fl);
        jt.setText(Integer.toString(value));

        return jt;

    }

    /**
     * Creates a new JTextField with the given name, double value and adds
     * a FocusListener.
     * @param name JTextField name.
     * @param value JTextField value.
     * @param fl FocusListener for this object's events
     * @return The newly formed JTextField.
     */
    public static JTextField createJTextField(String name, double value, FocusListener fl) {

        JTextField jt = _createJTextField(name, fl);
        jt.setText(Double.toString(value));

        return jt;

    }

    private static JTextField _createJTextField(String name, FocusListener fl) {

        JTextField jt = new JTextField();
        jt.setName(name);
        jt.addFocusListener(fl);

        return jt;

    }
}

Related

  1. createJTextField(Container c, String text, int x, int y, int width)
  2. createJTextField(Rectangle bounds)
  3. initJTextField(JTextField text, String element)
  4. initLabelComponent(final JLabel label, final JTextField textField)
  5. makeJTextField(Document d, String s, int len, Object listener)