2个回答
2015-12-01 · 知道合伙人数码行家
关注
展开全部
import java.awt.*;
import java.awt.event.*;
public class report extends Frame implements ActionListener
{
Panel p=new Panel();
Panel test = new Panel();//声名2个新的面版
Panel test2 =new Panel();
Button btn=new Button("退出");
Label label1 = new Label("This is test panel");
Label label2 = new Label("This is test2 panel");
MenuBar mb=new MenuBar();
Menu m1=new Menu("报表统计");
MenuItem day=new MenuItem("日报表");
MenuItem month=new MenuItem("月报表");
report()
{
super("report");
setSize(350,200);
add("South",p);
p.add(btn);
btn.addActionListener(this);
test.setVisible(false);//设置test,test2的默认为不显示
test2.setVisible(false);
test.add(label1);
test2.add(label2);
m1.add(day);
m1.add(month);
day.addActionListener(this);
month.addActionListener(this);
mb.add(m1);
setMenuBar(mb);
show();
}
public static void main(String args[])
{
new report();
}
public void actionPerformed(ActionEvent e)
{
if (e.getActionCommand()=="日报表")
{
p.setVisible(false);
add("South",test);
test2.setVisible(false);
test.setVisible(true);//更改test面版为显示
test.setBackground(Color.CYAN);//设置面板颜色
test.setSize(400,400);
}
else if (e.getActionCommand()=="月报表")
{
p.setVisible(false);
test.setVisible(false);
add("South",test2);
test2.setSize(400,400);
test2.setVisible(true);
test2.setBackground(Color.RED);
}
}
}
import java.awt.event.*;
public class report extends Frame implements ActionListener
{
Panel p=new Panel();
Panel test = new Panel();//声名2个新的面版
Panel test2 =new Panel();
Button btn=new Button("退出");
Label label1 = new Label("This is test panel");
Label label2 = new Label("This is test2 panel");
MenuBar mb=new MenuBar();
Menu m1=new Menu("报表统计");
MenuItem day=new MenuItem("日报表");
MenuItem month=new MenuItem("月报表");
report()
{
super("report");
setSize(350,200);
add("South",p);
p.add(btn);
btn.addActionListener(this);
test.setVisible(false);//设置test,test2的默认为不显示
test2.setVisible(false);
test.add(label1);
test2.add(label2);
m1.add(day);
m1.add(month);
day.addActionListener(this);
month.addActionListener(this);
mb.add(m1);
setMenuBar(mb);
show();
}
public static void main(String args[])
{
new report();
}
public void actionPerformed(ActionEvent e)
{
if (e.getActionCommand()=="日报表")
{
p.setVisible(false);
add("South",test);
test2.setVisible(false);
test.setVisible(true);//更改test面版为显示
test.setBackground(Color.CYAN);//设置面板颜色
test.setSize(400,400);
}
else if (e.getActionCommand()=="月报表")
{
p.setVisible(false);
test.setVisible(false);
add("South",test2);
test2.setSize(400,400);
test2.setVisible(true);
test2.setBackground(Color.RED);
}
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询