import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Jhello extends JFrame implements ActionListener {
/**
*
*/
private static final long serialVersionUID = 1L;
JTextField answer = new JTextField(25);
JLabel welcoming = new JLabel();
public Jhello () {
setLayout(new FlowLayout());
add(new JLabel("What is your name? ", JLabel.CENTER));
add(answer);
add(welcoming);
welcoming.setHorizontalAlignment(JLabel.CENTER);
answer.addActionListener(this);
setSize(350, 105);
setVisible(true);
setDefaultCloseOperation(EXIT_ON_CLOSE);
}
public static void main (String[] arg) {
new Jhello();
}
public void actionPerformed(ActionEvent e) {
String namne = answer.getText();
welcoming.setText("Welcome " + namne + "!");
}
}
No replies to this topic
#1
Posted 06 January 2010 - 10:12 AM
Here you go, no need to explain done it for people who just needs it...
|
|
|
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account


Back to top









