JAVAapplet一片空白,提示未初始化小程序JAVA

//<appletcode=hello.javaheight=100width=200></applet>importjava.applet.*;importjava.a... //<applet code=hello.java height=100 width=200></applet>
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class hello extends Applet implements ActionListener
{panela panel1;panelb panel2;Panel panel3;CardLayout card;//Button buttonok;paneld panel4;
Button button1;
public void init()
{setLayout (new BorderLayout());
card=new CardLayout();//buttonok=new Button("ok");
button1=new Button("ok");
panel3=new Panel();
panel1=new panela();
panel2=new panelb();
panel3.setLayout(card);
button1.addActionListener(this);
panel3.add(panel1);panel3.add(panel2);//panel4=new paneld();
add(panel3,"North");add(button1,"south");}
public void actionPerformed(ActionEvent e)
{if (e.getSource()==button1)
{card.next(panel3);}
}

}
class panela extends Panel implements ActionListener
{ TextField text;
Label label4,label2,label3,label5;
Button button1;
panela()
{text=new TextField("hello",10);
label4=new Label("请输入您的姓名");
label2=new Label(" Welcome to");
label3=new Label(" our net");
label5=new Label("ok?");
button1=new Button("ok");
setLayout(new GridLayout(3,2));
add(label2);add(label3);add(label4);add(text);add(label5);add(button1);
text.addActionListener(this);
button1.addActionListener(this);
text.setForeground(Color.blue);
text.setBackground(Color.yellow);}
public void actionPerformed(ActionEvent e)
{if (e.getSource()==text)
{text.setText("11");
}
if(e.getSource()==button1)
{label2.setVisible(false);
label3.setVisible(false);
label4.setVisible(false);
label5.setVisible(false);
button1.setVisible(false);
text.setVisible(false);} }

}
class panelb extends Panel implements ActionListener
{ TextField text1,text2,text3,text4;
Label label1,label2,label3,label4;
Button button1,button2;
panelb()
{label1=new Label("Welcome to register");
label2=new Label("your name");
label3=new Label("password");
label4=new Label("password again");
text1=new TextField();
text2=new TextField();
text3=new TextField();
button1=new Button("ok");
//text1=new TextField();
}
public void actionPerformed(ActionEvent e)
{if ((e.getSource()==button1)&&(text3.getText()==text4.getText()))
{button2=new Button("register sucessful");}
}
}
/*class panelc extends Panel implements ActionListener
{panela panel1;panelbpanel2;CardLayout card;
panelc()
{card=new CardLayout()
panel1=new panela();
panel2=new panelb();}
}*/
//class paneld extends Panel
//{Button button11=new Button("ok");
//}
3楼的大哥,可以和我说详细点吗?
panel3.add(panel1,"");
就可以panel3.add(panel1); 为什么就不行了?
展开
 我来答
mxm_1123
推荐于2016-01-14 · TA获得超过1779个赞
知道大有可为答主
回答量:496
采纳率:0%
帮助的人:0
展开全部
帮你改了下:可以启动了,其余的你自己来吧
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class hello extends Applet implements ActionListener
{panela panel1;panelb panel2;Panel panel3;CardLayout card;//Button buttonok;paneld panel4;
Button button1;
public void init()
{setLayout (new BorderLayout());
card=new CardLayout();//buttonok=new Button("ok");
button1=new Button("ok");
panel3=new Panel();
panel1=new panela();
panel2=new panelb();
panel3.setLayout(card);
button1.addActionListener(this);
panel3.add(panel1,"");
panel3.add(panel2,"");//panel4=new paneld();
add("North",panel3);add("South",button1);}
public void actionPerformed(ActionEvent e)
{if (e.getSource()==button1)
{card.next(panel3);}
}

}
class panela extends Panel implements ActionListener
{ TextField text;
Label label4,label2,label3,label5;
Button button1;
panela()
{text=new TextField("hello",10);
label4=new Label("请输入您的姓名");
label2=new Label(" Welcome to");
label3=new Label(" our net");
label5=new Label("ok?");
button1=new Button("ok");
setLayout(new GridLayout(3,2));
add(label2);add(label3);add(label4);add(text);add(label5);add(button1);
text.addActionListener(this);
button1.addActionListener(this);
text.setForeground(Color.blue);
text.setBackground(Color.yellow);}
public void actionPerformed(ActionEvent e)
{if (e.getSource()==text)
{text.setText("11");
}
if(e.getSource()==button1)
{label2.setVisible(false);
label3.setVisible(false);
label4.setVisible(false);
label5.setVisible(false);
button1.setVisible(false);
text.setVisible(false);} }

}
class panelb extends Panel implements ActionListener
{ TextField text1,text2,text3,text4;
Label label1,label2,label3,label4;
Button button1,button2;
panelb()
{label1=new Label("Welcome to register");
label2=new Label("your name");
label3=new Label("password");
label4=new Label("password again");
text1=new TextField();
text2=new TextField();
text3=new TextField();
button1=new Button("ok");
//text1=new TextField();
}
public void actionPerformed(ActionEvent e)
{if ((e.getSource()==button1)&&(text3.getText()==text4.getText()))
{button2=new Button("register sucessful");}
}
}
/*class panelc extends Panel implements ActionListener
{panela panel1;panelbpanel2;CardLayout card;
panelc()
{card=new CardLayout()
panel1=new panela();
panel2=new panelb();}
}*/
//class paneld extends Panel
//{Button button11=new Button("ok");
//}
狠心拒绝
2007-11-08 · TA获得超过371个赞
知道小有建树答主
回答量:374
采纳率:0%
帮助的人:319万
展开全部
????
改了哪里?
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式