packagetest;importjava.awt.BorderLayout;importjava.awt.FlowLayout;importjava.awt.event.ActionEvent;importjava.awt.event.ActionListener;importjavax.swing.ImageIcon;importj...
package test;import java.awt.BorderLayout;import java.awt.FlowLayout;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import javax.swing.ImageIcon;import javax.swing.JButton;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JPanel;public class MyFrame extends JFrame {public MyFrame(){this.setTitle("欢迎界面");JLabel label=new JLabel(new ImageIcon("1.jpg"));JButton bt=new JButton("进入系统");JButton bt1=new JButton("制作人:杨元曦 15031117");JPanel panel=new JPanel();FlowLayout layout=new FlowLayout(FlowLayout.CENTER, 5,20);panel.setLayout(layout);panel.add(bt);panel.add(bt1);this.add(label,BorderLayout.CENTER);this.add(panel, BorderLayout.SOUTH);bt.addActionListener(new ActionListener() {@Overridepublic void actionPerformed(ActionEvent e) {// TODO Auto-generated method stubMyDialog dialog=new MyDialog();dialog.setVisible(true);dispose();}});this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);this.setSize(600,450);this.setResizable(false);this.setLocationRelativeTo(null);this.setVisible(true);}public static void main(String[] args) {// TODO Auto-generated method stubnew MyFrame();}}
展开