?? 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("運行環(huán)境 : JDK1.5以上",JLabel.CENTER);
JLabel WarnLabel = new JLabel("警告 :......");
JLabel ContentLabel = new JLabel("版權(quán)所有, COPY者必究",JLabel.CENTER);
JLabel geshiLabel = new JLabel();
JButton OkButton = new JButton(" Ok ");
JLabel HeadLabel = new JLabel();
JLabel AuthorButton = new JLabel("關(guān)于作者",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,"關(guān)于萬年歷",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); //窗體本身的設(shè)置
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)); //設(shè)置間距效果不明顯
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注釋:希望大家多批評指導(dǎo) ";
if(source ==AuthorButton)
{
JOptionPane.showMessageDialog(null,msg,"作者簡介",JOptionPane.INFORMATION_MESSAGE);
}
}
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -