Java小程序问题!求解答!
class ButtonPanel extends Panel
{
ButtonPanel(String id)
{
setLayout(new BorderLayout());
add("Center",new Button(id));
}
}
public class Hello extends Applet
{
Button
first = new Button("first"),
second = new Button("second"),
third = new Button("third");
Panel cards = new Panel();
Panel p = new Panel();
CardLayout c1 = new CardLayout();
public void init()
{
setLayout(new CardLayout());
p.setLayout(new FlowLayout());
p.add(first);
p.add(second);
p.add(third);
cards.setLayout(c1);
//这三句cards都没有弹出,应该有反应才对啊!为什么n呢?求解,谢谢!
cards.add("first card",new ButtonPanel("the first one"));
cards.add("second card",new ButtonPanel("the second one"));
cards.add("third card",new ButtonPanel("the third one"));
add("North",p);
add("Center",cards);
}
public boolean action(Event evt,Object arg)
{
if(evt.target.equals(first))
c1.first(cards);
else if(evt.target.equals(second))
{
c1.first(cards);
c1.next(cards);
}
else if(evt.target.equals(third))
c1.last(cards);
else
return super.action(evt, arg);
return true;
}
}
搜索更多相关主题的帖子:
public second Hello cards class
----------------解决方案--------------------------------------------------------
提示: 作者被禁止或删除 内容自动屏蔽