| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 437 人关注过本帖
标题:[求助]卡片布局管理器求助
取消只看楼主 加入收藏
非專业浇水
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2006-8-2
收藏
 问题点数:0 回复次数:1 
[求助]卡片布局管理器求助

个人想写个小程序,无奈到卡片布局管理器那卡住了,不知道哪里编译错了.出问题处,插入了注释 //出问题处 大家可以搜索找到哪里,从那行开始便是插入事件的,可是怎么做就是不对,还希望大家帮忙.算是奢望吧,在公司请教了好多高手了,可惜看不起俺这新手,只能在论坛里试试了,希望有人看到帖子可以帮帮忙.

搜索更多相关主题的帖子: 管理器 卡片 
2006-08-02 00:51
非專业浇水
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2006-8-2
收藏
得分:0 

...代码有贴附件啊.....
直接发上来吧,刚才经过一位朋友的帮助已经能编译通过,不过执行的不对,我一下子开了107个窗口
//cache
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.*;

class KFrame extends JFrame
{
public KFrame()
{

super("沛偶工作室");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);
setSize(640,450);
}
}
class KPanel extends KFrame
{

JPanel panelmain;
JPanel panelmaingz1;
JPanel panelbuttongz1;

JPanel panelmaingz2;
JPanel panelbuttongz2;

JPanel panelmaingz3;
JPanel panelbuttongz3;

JPanel panelmaingz4;
JPanel panelbuttongz4;
JPanel panelcomgz41;
JPanel panelcomgz42;
JPanel panelcomgz43;
JPanel panelcomgz44;

public KPanel()
{
panelmaingz1=new JPanel();
panelmain=new JPanel();
panelbuttongz1=new JPanel();

panelmaingz2=new JPanel();
panelbuttongz2=new JPanel();

panelmaingz3=new JPanel();
panelbuttongz3=new JPanel();

panelmaingz4= new JPanel();
panelbuttongz4= new JPanel();
panelcomgz41=new JPanel();
panelcomgz42=new JPanel();
panelcomgz43=new JPanel();
panelcomgz44=new JPanel();
}

}

class Kobj extends KPanel
{
JLabel labelgz11;
JTextField textgz11;
JButton buttongz11;
JButton buttongz12;

JLabel labelgz21;
JPasswordField textgz21;
JButton buttongz21;
JButton buttongz22;
JButton buttongz23;

JLabel labelgz31;
JTextField textgz31;
JButton buttongz31;
JButton buttongz32;
JButton buttongz33;

JLabel labelgz41;
JLabel labelgz42;
JLabel labelgz43;
JLabel labelgz44;
JLabel labelgz45;
JLabel labelgz46;

JRadioButton rbbuttongz41;
JRadioButton rbbuttongz42;
ButtonGroup buttongroupgz41;

JComboBox comboxgz41;
JComboBox comboxgz42;
JComboBox comboxgz43;

JComboBox comboxgz44;
JComboBox comboxgz45;
JComboBox comboxgz46;

JComboBox comboxgz47;
JComboBox comboxgz48;
JComboBox comboxgz49;

JComboBox comboxgz410;
JComboBox comboxgz411;
JComboBox comboxgz412;


JButton buttongz41;
JButton buttongz42;
JButton buttongz43;

public Kobj()
{
labelgz11 = new JLabel("请输入数据源的名称:");
panelmaingz1.add(labelgz11);
textgz11 = new JTextField(".",12);
panelmaingz1.add(textgz11);
buttongz11= new JButton("下一步");
panelbuttongz1.add(buttongz11);
buttongz12= new JButton("取消");
panelbuttongz1.add(buttongz12);

labelgz21 = new JLabel("请输入SA用户的密码:");
panelmaingz2.add(labelgz21);
textgz21 = new JPasswordField("123456789",12);
panelmaingz2.add(textgz21);
buttongz23= new JButton("上一步");
panelbuttongz2.add(buttongz23);
buttongz21= new JButton("下一步");
panelbuttongz2.add(buttongz21);
buttongz22= new JButton("取消");
panelbuttongz2.add(buttongz22);

labelgz31 = new JLabel("请输入数据库的名称:");
panelmaingz3.add(labelgz31);
textgz31 = new JTextField("master",12);
panelmaingz3.add(textgz31);
buttongz33= new JButton("上一步");
panelbuttongz3.add(buttongz33);
buttongz31= new JButton("下一步");
panelbuttongz3.add(buttongz31);
buttongz32= new JButton("取消");
panelbuttongz3.add(buttongz32);

labelgz41= new JLabel("请选择您的合并方式");
panelmaingz4.add(labelgz41);
labelgz45= new JLabel("至");
panelmaingz4.add(labelgz45);
labelgz46= new JLabel("至");
panelmaingz4.add(labelgz46);
rbbuttongz41= new JRadioButton("按月合并");
buttongroupgz41= new ButtonGroup();
buttongroupgz41.add(rbbuttongz41);
panelcomgz41.add(rbbuttongz41);
rbbuttongz42= new JRadioButton("按日合并");
panelcomgz42.add(rbbuttongz42);
buttongroupgz41.add(rbbuttongz42);
String comboboxstrgz41[]={"年"};
comboxgz41= new JComboBox(comboboxstrgz41);
panelcomgz41.add(comboxgz41);
labelgz42= new JLabel("年");
panelcomgz41.add(labelgz42);
String comboboxstrgz42[]={"月"};
comboxgz42= new JComboBox(comboboxstrgz42);
panelcomgz41.add(comboxgz42);
labelgz43= new JLabel("月");
panelcomgz41.add(labelgz43);
String comboboxstrgz44[]={"年"};
comboxgz44= new JComboBox(comboboxstrgz44);
panelcomgz42.add(comboxgz44);
labelgz42= new JLabel("年");
panelcomgz42.add(labelgz42);
String comboboxstrgz45[]={"月"};
comboxgz45= new JComboBox(comboboxstrgz45);
panelcomgz42.add(comboxgz45);
labelgz43= new JLabel("月");
panelcomgz42.add(labelgz43);
String comboboxstrgz46[]={"日"};
comboxgz46= new JComboBox(comboboxstrgz46);
panelcomgz42.add(comboxgz46);
labelgz44= new JLabel("日");
panelcomgz42.add(labelgz44);
String comboboxstrgz47[]={"年"};
comboxgz47= new JComboBox(comboboxstrgz47);
panelcomgz43.add(comboxgz47);
labelgz42= new JLabel("年");
panelcomgz43.add(labelgz43);
String comboboxstrgz48[]={"月"};
comboxgz48= new JComboBox(comboboxstrgz48);
panelcomgz43.add(comboxgz48);
labelgz43= new JLabel("月");
panelcomgz43.add(labelgz43);
String comboboxstrgz410[]={"年"};
comboxgz410= new JComboBox(comboboxstrgz410);
panelcomgz44.add(comboxgz410);
labelgz42= new JLabel("年");
panelcomgz44.add(labelgz42);
String comboboxstrgz411[]={"月"};
comboxgz411= new JComboBox(comboboxstrgz411);
panelcomgz44.add(comboxgz411);
labelgz43= new JLabel("月");
panelcomgz44.add(labelgz43);
String comboboxstrgz412[]={"日"};
comboxgz412= new JComboBox(comboboxstrgz412);
panelcomgz44.add(comboxgz412);
labelgz44= new JLabel("日");
panelcomgz44.add(labelgz44);
buttongz43= new JButton("上一步");
panelbuttongz4.add(buttongz43);
buttongz41= new JButton("下一步");
panelbuttongz4.add(buttongz41);
buttongz42= new JButton("取消");
panelbuttongz4.add(buttongz42);
}
}

class Kout extends Kobj
{

CardLayout cardlayoutmain;

GridBagLayout gblayoutmaingz1;
GridBagConstraints gbcmaingz1;
FlowLayout layoutbuttongz1;

GridBagLayout gblayoutmaingz2;
GridBagConstraints gbcmaingz2;
FlowLayout layoutbuttongz2;

GridBagLayout gblayoutmaingz3;
GridBagConstraints gbcmaingz3;
FlowLayout layoutbuttongz3;

GridBagLayout gblayoutmaingz4;
GridBagConstraints gbcmaingz4;
FlowLayout layoutbuttongz4;
FlowLayout layoutrbgz4;
FlowLayout layoutcomgz41;
FlowLayout layoutcomgz42;
FlowLayout layoutcomgz43;
FlowLayout layoutcomgz44;
public Kout()
{
layoutbuttongz1 = new FlowLayout(FlowLayout.LEFT,10,10);
panelbuttongz1.setLayout(layoutbuttongz1);
panelmaingz1.add(panelbuttongz1);
gblayoutmaingz1=new GridBagLayout();
gbcmaingz1=new GridBagConstraints();
panelmaingz1.setLayout(gblayoutmaingz1);
gbcmaingz1.gridx=1;
gbcmaingz1.gridy=1;
gbcmaingz1.anchor=GridBagConstraints.EAST;
gblayoutmaingz1.setConstraints(labelgz11,gbcmaingz1);
gbcmaingz1.gridx=2;
gbcmaingz1.anchor=GridBagConstraints.WEST;
gblayoutmaingz1.setConstraints(textgz11,gbcmaingz1);
gbcmaingz1.gridx=3;
gbcmaingz1.gridy=3;
gbcmaingz1.anchor=GridBagConstraints.EAST;
gblayoutmaingz1.setConstraints(panelbuttongz1,gbcmaingz1);
getContentPane().add(panelmaingz1);

layoutbuttongz2 = new FlowLayout(FlowLayout.LEFT,10,10);
panelbuttongz2.setLayout(layoutbuttongz2);
panelmaingz2.add(panelbuttongz2);
gblayoutmaingz2=new GridBagLayout();
gbcmaingz2=new GridBagConstraints();
panelmaingz2.setLayout(gblayoutmaingz2);
gbcmaingz2.gridx=1;
gbcmaingz2.gridy=1;
gbcmaingz2.anchor=GridBagConstraints.EAST;
gblayoutmaingz2.setConstraints(labelgz21,gbcmaingz2);
gbcmaingz2.gridx=2;
gbcmaingz2.anchor=GridBagConstraints.WEST;
gblayoutmaingz2.setConstraints(textgz21,gbcmaingz2);
gbcmaingz2.gridx=3;
gbcmaingz2.gridy=3;
gbcmaingz2.anchor=GridBagConstraints.CENTER;
gblayoutmaingz2.setConstraints(panelbuttongz2,gbcmaingz2);
getContentPane().add(panelmaingz2);

layoutbuttongz3 = new FlowLayout(FlowLayout.LEFT,10,10);
panelbuttongz3.setLayout(layoutbuttongz3);
panelmaingz3.add(panelbuttongz3);
gblayoutmaingz3=new GridBagLayout();
gbcmaingz3=new GridBagConstraints();
panelmaingz3.setLayout(gblayoutmaingz3);
gbcmaingz3.gridx=1;
gbcmaingz3.gridy=1;
gbcmaingz3.anchor=GridBagConstraints.EAST;
gblayoutmaingz3.setConstraints(labelgz31,gbcmaingz3);
gbcmaingz3.gridx=2;
gbcmaingz3.anchor=GridBagConstraints.WEST;
gblayoutmaingz3.setConstraints(textgz31,gbcmaingz3);
gbcmaingz3.gridx=3;
gbcmaingz3.gridy=3;
gbcmaingz3.anchor=GridBagConstraints.CENTER;
gblayoutmaingz3.setConstraints(panelbuttongz3,gbcmaingz3);
getContentPane().add(panelmaingz3);

layoutcomgz41 = new FlowLayout(FlowLayout.LEFT,10,10);
panelcomgz41.setLayout(layoutcomgz41);
panelmaingz4.add(panelcomgz41);
layoutcomgz42 = new FlowLayout(FlowLayout.LEFT,10,10);
panelcomgz42.setLayout(layoutcomgz42);
panelmaingz4.add(panelcomgz42);
layoutcomgz43 = new FlowLayout(FlowLayout.LEFT,10,10);
panelcomgz43.setLayout(layoutcomgz43);
panelmaingz4.add(panelcomgz43);
layoutcomgz44 = new FlowLayout(FlowLayout.LEFT,10,10);
panelcomgz44.setLayout(layoutcomgz44);
panelmaingz4.add(panelcomgz44);
layoutbuttongz4=new FlowLayout(FlowLayout.LEFT,10,10);
panelbuttongz4.setLayout(layoutbuttongz4);
panelmaingz4.add(panelbuttongz4);
gblayoutmaingz4=new GridBagLayout();
gbcmaingz4=new GridBagConstraints();
panelmaingz4.setLayout(gblayoutmaingz4);
gbcmaingz4.gridx=1;
gbcmaingz4.gridy=1;
gbcmaingz4.anchor=GridBagConstraints.WEST;
gblayoutmaingz4.setConstraints(labelgz41,gbcmaingz4);
gbcmaingz4.gridx=1;
gbcmaingz4.gridy=2;
gbcmaingz4.anchor=GridBagConstraints.WEST;
gblayoutmaingz4.setConstraints(panelcomgz41,gbcmaingz4);
gbcmaingz4.gridx=2;
gblayoutmaingz4.setConstraints(labelgz45,gbcmaingz4);
gbcmaingz4.gridx=3;
gblayoutmaingz4.setConstraints(panelcomgz43,gbcmaingz4);
gbcmaingz4.gridx=1;
gbcmaingz4.gridy=3;
gbcmaingz4.anchor=GridBagConstraints.WEST;
gblayoutmaingz4.setConstraints(panelcomgz42,gbcmaingz4);
gbcmaingz4.gridx=2;
gblayoutmaingz4.setConstraints(labelgz46,gbcmaingz4);
gbcmaingz4.gridx=3;
gblayoutmaingz4.setConstraints(panelcomgz44,gbcmaingz4);
gbcmaingz4.gridx=4;
gbcmaingz4.gridy=4;
gbcmaingz4.anchor=GridBagConstraints.CENTER;
gblayoutmaingz4.setConstraints(panelbuttongz4,gbcmaingz4);
getContentPane().add(panelmaingz4);




cardlayoutmain=new CardLayout();
panelmain.setLayout(cardlayoutmain);
panelmain.add("k1",panelmaingz1);
panelmain.add("k2",panelmaingz2);
panelmain.add("k3",panelmaingz3);
panelmain.add("k4",panelmaingz4);
cardlayoutmain.show(panelmain,"k1");
getContentPane().add(panelmain);
}
}

class KEvent extends Kout //出问题处
{
ButtonEvent bEObj;
public KEvent()
{
bEObj=new ButtonEvent();
buttongz11.addActionListener(bEObj);
buttongz12.addActionListener(bEObj);
buttongz21.addActionListener(bEObj);
buttongz22.addActionListener(bEObj);
buttongz23.addActionListener(bEObj);
buttongz31.addActionListener(bEObj);
buttongz32.addActionListener(bEObj);
buttongz32.addActionListener(bEObj);
buttongz41.addActionListener(bEObj);
buttongz42.addActionListener(bEObj);
buttongz43.addActionListener(bEObj);
}
}
class ButtonEvent extends KEvent implements ActionListener
{


public void actionPerformed(java.awt.event.ActionEvent e)
{
Object obj=e.getSource();
if(obj==buttongz11)
cardlayoutmain.show(panelmain,"k2");
if(obj==buttongz21)
cardlayoutmain.show(panelmain,"k3");
if(obj==buttongz23)
cardlayoutmain.show(panelmain,"k2");
if(obj==buttongz31)
cardlayoutmain.show(panelmain,"k3");
if(obj==buttongz33)
cardlayoutmain.show(panelmain,"k2");
if(obj==buttongz41)
cardlayoutmain.show(panelmain,"k3");
if(obj==buttongz43)
cardlayoutmain.show(panelmain,"k2");
}
}

public class cache
{
public static void main(String[] args)
{
new ButtonEvent();
}
}

2006-08-02 01:52
快速回复:[求助]卡片布局管理器求助
数据加载中...
 
   



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

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