| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 514 人关注过本帖
标题: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
快速回复:wrong parent for cardlayout?????
数据加载中...
 
   



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

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