1个回答
展开全部
import javax.swing.*;import java.applet.*;
class MyPanel extends JPanel{
JButton button1,button2;
JLabel label;
MyPanel(String s1,String s2,String s3){
button1=new JButton(s1);
button2=new JButton(s2);
label=new JLabel(s3);
add(button1);add(button2);add(label);
}
}
public class Example5_4 extends Applet{
MyPanel panel1,panel2;
JButton button;
public void init(){
panel1=new MyPanel("确定","取消","标签,我们在面板1中");
panel2=new MyPanel("确定","取消","标签,我们在面板2中");
button=new JButton("我是不在面板中的按钮");
add(panel1);add(panel2);add(button);
setSize(300,200);
}
}
class MyPanel extends JPanel{
JButton button1,button2;
JLabel label;
MyPanel(String s1,String s2,String s3){
button1=new JButton(s1);
button2=new JButton(s2);
label=new JLabel(s3);
add(button1);add(button2);add(label);
}
}
public class Example5_4 extends Applet{
MyPanel panel1,panel2;
JButton button;
public void init(){
panel1=new MyPanel("确定","取消","标签,我们在面板1中");
panel2=new MyPanel("确定","取消","标签,我们在面板2中");
button=new JButton("我是不在面板中的按钮");
add(panel1);add(panel2);add(button);
setSize(300,200);
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询