📄 authordialog.java
字号:
import java.awt.event.*;
import javax.swing.*;
import java.awt.*;
class AuthorDialog extends JDialog
{
JLabel NameLabel = new JLabel("名称 : 万年历");
JLabel VersionLabel = new JLabel("版本 : 1.0.0 ",JLabel.CENTER);
JLabel AuthorLabel = new JLabel("作者 : 04JS008",JLabel.CENTER);
JLabel ConditionLabel = new JLabel("运行环境 : JDK1.5以上",JLabel.CENTER);
JLabel WarnLabel = new JLabel("警告 :......");
JLabel ContentLabel = new JLabel("版权所有, COPY者必究",JLabel.CENTER);
JLabel geshiLabel = new JLabel();
JButton OkButton = new JButton(" Ok ");
JLabel HeadLabel = new JLabel();
JLabel AuthorButton = new JLabel("关于作者",JLabel.CENTER);
ImageIcon NameImage = new ImageIcon("image/Book.gif");
ImageIcon WarnImage = new ImageIcon("image/warn.gif");
ImageIcon HeadImage = new ImageIcon("image/head.jpg");
JPanel panel1 = new JPanel();
JPanel panel2 = new JPanel();
JPanel panel3 = new JPanel();
JPanel panel4 = new JPanel();
public AuthorDialog(JFrame frame ,String s,boolean b)
{
super(frame,"关于万年历",b);
this.setSize(250,320);
this.setResizable(false);
this.setDefaultCloseOperation(JDialog.EXIT_ON_CLOSE);// JDialog.DO_NOTHING_ON_CLOSE
int w,h;
w = this.getWidth();
h = this.getHeight();
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
this.setLocation((d.width-w)/2,(d.height-h)/2); //窗体本身的设置
NameLabel.setIcon(NameImage);
WarnLabel.setIcon(WarnImage);
HeadLabel.setIcon(HeadImage);
HeadLabel.setBorder(BorderFactory.createLoweredBevelBorder());
OkButton.setForeground(Color.red);
OkButton.setBackground(Color.LIGHT_GRAY);
OkButton.addActionListener(new Click());
AuthorButton.setToolTipText(" ^+^ Click ^+^ ");
AuthorButton.addMouseListener(new Click());
panel1.setLayout(new GridLayout(4,0,1,1)); //设置间距效果不明显
panel2.setLayout(new GridLayout(4,1));
panel3.setLayout(new GridLayout(2,0));
panel1.add(NameLabel);
panel1.add(VersionLabel);
panel1.add(AuthorLabel);
panel1.add(ConditionLabel);
panel2.add(WarnLabel);
panel2.add(ContentLabel);
panel2.add(geshiLabel);
panel2.add(OkButton);
panel3.add(HeadLabel);
panel3.add(AuthorButton);
add(panel1,BorderLayout.WEST);
add(panel3,BorderLayout.EAST); //位置不能变由于格式的原因
add(panel2,BorderLayout.SOUTH);
this.setVisible(true);
}
class Click extends MouseAdapter implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
Object source = e.getSource();
if(source==OkButton)
{
dispose();
}
}
public void mouseClicked(MouseEvent e)
{
Object source = e.getSource();
String msg = "绰号: 耗子\n爱好:编程,交友\nQQ : 345980723\nEmail :luhao322@yahoo.com.cn\n注释:希望大家多批评指导 ";
if(source ==AuthorButton)
{
JOptionPane.showMessageDialog(null,msg,"作者简介",JOptionPane.INFORMATION_MESSAGE);
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -