📄 aboutdialog.java
字号:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;
public class AboutDialog
extends JDialog
implements ActionListener {
private JPanel panel1 = new JPanel();
private JPanel panel2 = new JPanel();
private JPanel insetsPanel1 = new JPanel();
private JPanel insetsPanel2 = new JPanel();
private JPanel insetsPanel3 = new JPanel();
private JButton exitButton = new JButton();
private JLabel imageLabel = new JLabel("", SwingConstants.CENTER);
private JLabel authorLabel = new JLabel();
private JLabel softwareNameLabel = new JLabel();
private JLabel programLabel = new JLabel();
private JLabel grade = new JLabel();
private ImageIcon copyrightImage = new ImageIcon();
private GridLayout gridLayout = new GridLayout(5, 1);
private JLabel dateOfPro = new JLabel();
int ScreenWidth,ScreenHeight;
public AboutDialog() {
setTitle("JDialog Test");
init();
setResizable(true);
pack();
ScreenWidth = getToolkit().getScreenSize().width;//将窗口置于屏幕中央,宽度与高度皆为屏幕一半
ScreenHeight = getToolkit().getScreenSize().height;
setLocation((ScreenWidth - getWidth()) / 2,(ScreenHeight - getHeight()) / 2);
show();
}
public static void main(String args[]) //测试函数
{
new AboutDialog();
}
private void init() {
setTitle("关于作者");
copyrightImage = new ImageIcon(AboutDialog.class.getResource("images\\hand.png"));
imageLabel.setIcon(copyrightImage);
panel1.setLayout(new BorderLayout());
panel2.setLayout(new BorderLayout());
insetsPanel1.setLayout(new FlowLayout());
insetsPanel2.setLayout(new FlowLayout());
insetsPanel3.setLayout(gridLayout);
softwareNameLabel.setText(" 计算机网络课程设计");
softwareNameLabel.setToolTipText("Java 语言");
softwareNameLabel.setFont(new Font("Monospaced", Font.PLAIN, 15));
programLabel.setText(" ----简单ICQ聊天程序");
programLabel.setToolTipText("ICQ聊天程序");
programLabel.setFont(new Font("Monospaced", Font.PLAIN, 15));
grade.setText(" 05软件学院软件工程(9)班 ");
grade.setToolTipText("班级");
grade.setFont(new Font("Monospaced", Font.PLAIN, 15));
authorLabel.setText(" 龙全永(200530690914) ");
authorLabel.setToolTipText("编写人");
authorLabel.setFont(new Font("Monospaced", Font.PLAIN, 15));
dateOfPro.setToolTipText("编写时间");
dateOfPro.setText(" 2008/2/16");
dateOfPro.setFont(new Font("Monospaced", Font.PLAIN, 15));
exitButton.setText("退出");
exitButton.setFont(new Font("Monospaced", Font.BOLD, 15));
exitButton.setCursor(new Cursor(Cursor.HAND_CURSOR));
exitButton.addActionListener(this);
insetsPanel2.add(imageLabel, null);
panel2.add(insetsPanel2, BorderLayout.WEST);
insetsPanel3.add(softwareNameLabel, null);
insetsPanel3.add(programLabel, null);
insetsPanel3.add(grade, null);
insetsPanel3.add(authorLabel, null);
insetsPanel3.add(dateOfPro, null);
panel2.add(insetsPanel3, BorderLayout.CENTER);
insetsPanel1.add(exitButton, null);
panel1.add(insetsPanel1, BorderLayout.SOUTH);
panel1.add(panel2, BorderLayout.NORTH);
getContentPane().add(panel1, null);
}
public Dimension getPreferredSize() {
return new Dimension(300, 200);
}
// public void processWindowEvent(WindowEvent e) {
// if (e.getID() == WindowEvent.WINDOW_CLOSING) {
// dispose();
// }
// super.processWindowEvent(e);
// }
public void actionPerformed(ActionEvent e) {
if (e.getSource() == exitButton) {
dispose();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -