Anirudh Singh Gaur
tTextField
1 Answer(s)      4 years and 3 months ago
Posted in : Java Beginners

How to create "ttextfield" in java? please give a demo code of it.

Advertisement
View Answers

May 12, 2011 at 11:17 AM


import java.awt.*;
import java.sql.*;
import javax.swing.*;
import java.awt.event.*;

class TextFieldExample {
    public static void main(String[] args) {
        Frame f = new Frame();
        Label label = new Label("Name: ");
        final TextField text = new TextField(20);
        Button b = new Button("Show");
        b.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                String value = text.getText();
                JOptionPane.showMessageDialog(null, "Hello " + value);

            }
        });
        Panel p = new Panel(new GridLayout(2, 2));
        p.add(label);
        p.add(text);
        p.add(b);
        f.add(p);
        f.setVisible(true);
        f.pack();
    }
}









Related Tutorials/Questions & Answers:
tTextField
tTextField  How to create "ttextfield" in java? please give a demo code
tTextField
tTextField  How to create "ttextfield" in java? please give a demo code
Advertisements