标题:wrong parent for cardlayout?????
取消只看楼主
chaiyesong
Rank: 2
等 级:论坛游民
威 望:3
帖 子:70
专家分:44
注 册:2014-5-14
结帖率:77.78%
已结贴  问题点数:1 回复次数:2 
wrong parent for cardlayout?????
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class testCard
{
    public static void main(String [] args)
    {
        demo_8 test=new demo_8();
    }
}

 class demo_8 extends JFrame  
 {
     JPanel jp;//最底部的面板
     JPanel jpNorth;//放置card的面板
     JPanel jpButton;//放置按钮的面板
     JPanel jp1;
     JPanel jp2;
     JPanel jp3;
     JPanel jp4;
     JPanel jp5;
     JButton jb1;
     JButton jb2;
     CardLayout card=new CardLayout();
     public demo_8()
     {
         jp=new JPanel();
         jpButton=new JPanel();
         this.setBounds(0,0,400,300);
         this.setVisible(true);
         this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         this.setContentPane(jp);
         jpNorth=new JPanel();
         jp.add(jpNorth,BorderLayout.CENTER);
         jpNorth.setLayout(card);
         jp1=new JPanel();
         jp2=new JPanel();
         jp3=new JPanel();
         jp4=new JPanel();
         jp5=new JPanel();
         jb1=new JButton("jb1");
         jb2=new JButton("jb2");
         jp.add(jpButton,BorderLayout.SOUTH);
         jpButton.add(jb1);
         jpButton.add(jb2);
         card.addLayoutComponent(jp1,"jp1");
         card.addLayoutComponent(jp2,"jp2");
         card.addLayoutComponent(jp3,"jp3");
         card.addLayoutComponent(jp4,"jp4");
         jb1.addActionListener
         (
             new ActionListener()
             {
                 public void actionPerformed(ActionEvent e)
                 {
                     card.previous(jp2);
                 }
             }
         );
         jb2.addActionListener(
             new ActionListener()
             {
                 public void actionPerformed(ActionEvent e)
                 {
                     card.next(jp1);
                 }
                 
             }
         );
     }
 }


报错图:

搜索更多相关主题的帖子: parent public import wrong 
2014-05-15 11:27
chaiyesong
Rank: 2
等 级:论坛游民
威 望:3
帖 子:70
专家分:44
注 册:2014-5-14
得分:0 
这个程序是我自己写的我用ediplus编写的 ??
我也找不出原因,在网上也没找到答案,所以在此请教各位大神,还望楼上的不吝赐教,呵呵呵额 谢谢
2014-05-17 21:56
chaiyesong
Rank: 2
等 级:论坛游民
威 望:3
帖 子:70
专家分:44
注 册:2014-5-14
得分:0 
哦 找到了  谢谢 是我的放置方法弄错了 ,谢谢提醒
2014-05-17 21:57



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-431566-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.271517 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved