Java实现 import java.awt.Dimension; import java.awt.GridLayout; import java.awt.Toolkit; import java.awt.event.*;import javax.swing.JButton; import javax.swing.JFrame;public class mainframe { static final int WIDTH = 400; static final int
import java.awt.Dimension; import java.awt.GridLayout; import java.awt.Toolkit; import java.awt.event.*; import javax.swing.JButton; import javax.swing.JFrame; public class mainframe { static final int WIDTH = 400; static final int HEIGHT = 200; //JFrame buttonframe; public mainframe(){ JFrame buttonframe = new JFrame(“学校信息管理系统”); //buttonframe.setTitle(“学校信息管理系统”); buttonframe .setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); buttonframe.setSize(WIDTH, HEIGHT); Toolkit kit = Toolkit.getDefaultToolkit(); //获取屏幕的大小对象 Dimension screenSize = kit.getScreenSize(); int width = screenSize.width; int height = screenSize.height; int x = (width-WIDTH)/2; int y = (height - HEIGHT)/2; buttonframe.setLocation(x, y); buttonframe.setVisible(true); JButton student = new JButton("学生信息系统模块"); JButton teacher = new JButton("教师信息系统模块"); JButton leader = new JButton("领导信息系统模块"); buttonframe.add(student); buttonframe.add(teacher); buttonframe.add(leader); buttonframe.setLayout(new GridLayout(3, 1)); student.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent Event){ studentmanageframe studentframe = new studentmanageframe(); } }); teacher.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent Event){ teachermanageframe teacherframe = new teachermangerframe(); } }); leader.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent Event){ leadermanageframe leaderframe = new leadermanageframe(); } }); } }