awt 질문입니다..좀 알려주세요..
바론
예전에 자바 공부 할려고 가입했었는데 이제 염치없이 글을 올리네요..;;;
예제 소스를 작성했는데...도저히 에러 원인을 모르겠습니다...좀 알려주세요..;;;
import java.awt.*;
import java.awt.event.*;
public class CardWithButton extends frame implements ActionListener{
Panel card;
Button b1,b2,b3,b4;
static int k = 0;
public CardWithButton(String title){
super(title);
card = new Panel();
card.setLayout(new CardLayout());
setForeground(Color.black);
setBackground(Color.orange);
b1=new Button(One);
b2=new Button(Two);
b3=new Button(Three);
b4=new Button(Four);
b1.setBackground(Color.red);
b2.setBackground(Color.yellow);
b3.setBackground(Color.blue);
b4.setBackground(Color.green);
b1.addActionListener(this);
b2.addActionListener(this);
b3.addActionListener(this);
b4.addActionListener(this);
card.add(One,b1);
card.add(Two,b2);
card.add(Three,b3);
card.add(Four,b4);
add(Center,card);
}
public static void main(String args[]){
CardWithButton cb = new CardWithButton(CardLayout);
cb.setSize(100,100);
cb.setVisible(true);
}
public void actionPerformed(ActionEvent e){
k=k%4;
switch(k){
case 0 :((CardLayout)card.getLayout()).show(card,One);
break;
case 1 :((CardLayout)card.getLayout()).show(card,Two);
break;
case 2 :((CardLayout)card.getLayout()).show(card,Three);
break;
case 3 :((CardLayout)card.getLayout()).show(card,Four);
break;
}
k++;
}
}
-
일진오빠
아..감사 합니다..^^
-
유메
extends frame --- extends Frame