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); 为什么就不行了? 展开
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); 为什么就不行了? 展开
2个回答
展开全部
帮你改了下:可以启动了,其余的你自己来吧
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");
//}
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");
//}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询