package java_samples_hwang;
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
/**
*
* @author hwang
*/
public class SwingDemo {
JTextField txtfld ;
public void createGUI()
{
JFrame frame = new JFrame("Hello World Swing");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container cp = frame.getContentPane();
JButton button = new JButton("push button");
txtfld = new JTextField(20);
cp.setLayout(new FlowLayout());
ActionListener al = new ActionListener() {
public void actionPerformed(ActionEvent e)
{
txtfld.setText("button clicked");
}
};
button.addActionListener(al);
cp.add(button);
cp.add(txtfld);
frame.pack();
frame.setVisible(true);
}
}
class SwingEx
{
public static void main(String args[])
{
SwingDemo obj = new SwingDemo();
obj.createGUI();
}
}
'백엔드기술 > 개발언어' 카테고리의 다른 글
Shuffle Array (0) | 2009.12.09 |
---|---|
Parser Demo (0) | 2009.12.09 |
Override Demo (0) | 2009.12.09 |