今晚就要交作业了!!!跪求大神帮帮忙!第一个界面:importjava.awt.Color;importjava.awt.Font;importjava.awt.GridLayout;importjava.awt.event.ActionEvent;importjava.awt.event...
今晚就要交作业了!!!跪求大神帮帮忙!第一个界面:import java.awt.Color;import java.awt.Font;import java.awt.GridLayout;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import javax.management.openmbean.OpenDataException;import javax.swing.ImageIcon;import javax.swing.JButton;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JPanel;public class First extends JFrame implements ActionListener{JPanel firstpane,pp,p1,p2,p3,p4;JButton jb1,jb2;JLabel L2;Font fontjb =new Font("幼圆", Font.CENTER_BASELINE,20);public First(){/***************中部面板***************/pp=(JPanel) getContentPane();pp.setBackground(Color.CYAN);pp.setLayout(new GridLayout(3,8));jb1=new JButton("进入-汽车租赁系统");jb2=new JButton("退出-汽车租赁系统");jb1.setFont(fontjb);jb2.setFont(fontjb);jb1.setBackground(Color.yellow);jb2.setBackground(Color.yellow);jb1.setForeground(Color.blue);jb2.setForeground(Color.blue);jb1.addActionListener(null);pp.add(new JLabel(new ImageIcon("IMAGE\\car1.jpg")));pp.add(jb1);pp.add(jb2);/**************************************/}public static void main(String[] args) {First f=new First();f.setTitle("汽车租赁系统");f.setSize(500,500);f.setDefaultCloseOperation(EXIT_ON_CLOSE);f.setVisible(true);}public void actionPerformed(ActionEvent e){this.dispose();second s=new second();s.setVisible(true);}}是这样的两个Java文件 怎么点第一个出现第二个呢
第二个界面:
public class second extends JFrame{
JPanel p;
JButton d,x,n,b,z;
public second(){
p=(JPanel) getContentPane();
p.setLayout(new BorderLayout(6,6));
d=new JButton("中");
x=new JButton("西");
n=new JButton("南");
b=new JButton("北");
z=new JButton("中");
p.add(d,BorderLayout.EAST);
p.add(x,BorderLayout.WEST);
p.add(n,BorderLayout.SOUTH);
p.add(b,BorderLayout.NORTH);
p.add(z,BorderLayout.CENTER);
}
public static void main(String[] args) {
second t=new second();
t.setVisible(true);
}
}
展开