一个简单的学生信息查询系统
源代码在线查看: about.java
//About.java
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class About extends JFrame {
JLabel label;
JButton button;
// 生成一个窗口
public About() {
super("关于");
setSize(250, 115);
setAlwaysOnTop(true);
label = new JLabel();
label.setText("制作者:赵坤");
button = new JButton();
button.setText("确定");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
setVisible(false);
}
});
Container con = getContentPane();
con.setLayout(null);
label.setBounds(85, 10, 82, 25);
button.setBounds(95, 55, 60, 25);
con.add(label);
con.add(button);
// 将窗口置于屏幕中央
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
Dimension frameSize = this.getSize();
if (frameSize.height > screenSize.height) {
frameSize.height = screenSize.height;
}
if (frameSize.width > screenSize.width) {
frameSize.width = screenSize.width;
}
setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2);
setResizable(false);
setVisible(true);
}
}