怎么在java窗口菜单程序中跳转到另一个页面???
我有一段java窗口菜单程序:importjava.awt.*;importjava.awt.event.*;publicclassreportextendsFramei...
我有一段java窗口菜单程序:
import java.awt.*;
import java.awt.event.*;
public class report extends Frame implements ActionListener{
Panel p=new Panel();
Button btn=new Button("退出");
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);
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()=="日报表")
(跳转到日报表页面report.jsp)????
else if (e.getActionCommand()=="月报表")
(跳转到月报表页面)??????
}
}
请问当打开这个窗口时,当按下“日报表”时,怎么跳转到日报表的report.jsp页面,并在该窗口中执行????
谢谢! 展开
import java.awt.*;
import java.awt.event.*;
public class report extends Frame implements ActionListener{
Panel p=new Panel();
Button btn=new Button("退出");
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);
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()=="日报表")
(跳转到日报表页面report.jsp)????
else if (e.getActionCommand()=="月报表")
(跳转到月报表页面)??????
}
}
请问当打开这个窗口时,当按下“日报表”时,怎么跳转到日报表的report.jsp页面,并在该窗口中执行????
谢谢! 展开
1个回答
展开全部
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);
}
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询