Anirudh Singh Gaur
tTextField
1 Answer(s)      2 years ago
Posted in : Java Beginners

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

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 Pages:
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

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.