当前位置: 代码迷 >> Java Web开发 >> Java小程序问题!求解答!
  详细解决方案

Java小程序问题!求解答!

热度:200   发布时间:2011-10-16 16:46:53.0
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  

----------------解决方案--------------------------------------------------------
提示: 作者被禁止或删除 内容自动屏蔽
2011-10-16 09:49:37
daemon1

等 级:新手上路
帖 子:72
专家分:3
注 册:2011-4-14
3
  得分:0 
回复 2楼 付政委
谢谢!不过我明白这样好像只是分开操作cards而已啊!为什么又能运行呢!求解答!
----------------解决方案--------------------------------------------------------
  相关解决方案