📄 aboutbox.java
字号:
package test;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;
public class AboutBox extends JDialog implements ActionListener {
private JPanel mainPanel = new JPanel();
private JPanel buttonPanel = new JPanel();
private JButton okBttn = new JButton();
private JLabel imageLabel = new JLabel();
private JLabel productLabel = new JLabel();
private JLabel versionLabel = new JLabel();
private JLabel copyrightLabel = new JLabel();
private GridLayout mainLayout = new GridLayout();
private static final String product = "音乐播放器";
private static final String version = "1.0";
private static final String copyright = "Copyright (c) TestCompany";
public AboutBox(Frame parent) {
super(parent);
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
try {
GuiInit();
}
catch(Exception e) {
e.printStackTrace();
}
pack();
}
private void GuiInit() throws Exception {
this.setTitle("关于");
setResizable(false);
mainPanel.setLayout(mainLayout);
buttonPanel.setLayout(new BorderLayout() );
mainPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
mainLayout.setRows(4);
mainLayout.setColumns(1);
productLabel.setText(product);
versionLabel.setText(version);
copyrightLabel.setText(copyright);
okBttn.setText("确定");
okBttn.addActionListener(this);
buttonPanel.add(okBttn);
mainPanel.add(productLabel, null);
mainPanel.add(versionLabel, null);
mainPanel.add(copyrightLabel, null);
this.getContentPane().add(mainPanel, BorderLayout.NORTH);
this.getContentPane().add(buttonPanel, null);
}
protected void processWindowEvent(WindowEvent e) {
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
dispose();
}
super.processWindowEvent(e);
}
public void actionPerformed(ActionEvent e) {
if (e.getSource() == okBttn) {
dispose();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -