±Û¾´ÀÌ :À̼ºÈÆ 1999³â 11¿ù 19ÀÏ 12:18:46
In Reply to: JFrame¿¡¼ component Ãß°¡, »èÁ¦´Â ¾î¶»°Ô... posted by ÀÓÁظð on 1999³â 11¿ù 19ÀÏ 10:14:26:
Á¦°¡ ÁÖ·Î ¾²´Â ¹æ¹ýÀä.
¾Æ·¡ Äڵ带 Âü°íÇϼ¼¿ä.
------------------------------------------------------------
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
public class CompTest extends JFrame implements ActionListener {
JButton b1;
JButton b2;
JButton b3;
public CompTest() { this("Anonymous"); }
public CompTest (String s) {
super(s);
b1 = new JButton("Button1");
b2 = new JButton("Button2");
b3 = new JButton("Button3");
b3.addActionListener(this);
this.getContentPane().setLayout( new BorderLayout());
this.getContentPane().add("Center", b1);
this.getContentPane().add("South", b3);
this.setSize(400,300);
this.setVisible(true);
}
public void actionPerformed(ActionEvent ae) {
this.remove(b1);
this.getContentPane().add("Center", b2);
this.validate();
}
public static void main(String args[]) {
new CompTest("Hi all");
}
}