Example usage for javax.swing JTextField JTextField

List of usage examples for javax.swing JTextField JTextField

Introduction

In this page you can find the example usage for javax.swing JTextField JTextField.

Prototype

public JTextField(Document doc, String text, int columns) 

Source Link

Document

Constructs a new JTextField that uses the given text storage model and the given number of columns.

Usage

From source file:MaxLengthDocument.java

public static void main(String[] args) {
    Document doc = new MaxLengthDocument(5);
    JTextField field = new JTextField(doc, "", 8);

    JPanel flowPanel = new JPanel();
    flowPanel.add(field);/*from  www.  j  av a  2s  . com*/
    JFrame frame = new JFrame("MaxLengthDocument demo");
    frame.setContentPane(flowPanel);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setSize(160, 80);
    frame.setVisible(true);
}

From source file:MaxLengthDocument.java

public static void main(String[] a) {
    Document doc = new MaxLengthDocument(5); // set maximum length to 5
    JTextField field = new JTextField(doc, "", 8);

    JPanel flowPanel = new JPanel();
    flowPanel.add(field);/*  w w w  .  j  av a2 s  .  c  om*/
    JFrame frame = new JFrame("MaxLengthDocument demo");
    frame.setContentPane(flowPanel);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setSize(160, 80);
    frame.setVisible(true);
}