Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Anirudh Singh Gaur
tTextField
1 Answer(s)      3 years and 5 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
 

 

 

DMCA.com