📄 msgdialog.java
字号:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
/**
* Prompt some message to user.<p>
* 2005.9.4
* @version 0.1.2
* @author Daxin Tian
*
*/
public class MsgDialog extends Frame implements ActionListener{
/**
* Button OK. If Clicked this dialog will be closed.
*/
JButton b_ok;
/**
* The prompt message will be writed in it.
*/
JLabel l_msg;
MsgDialog()
{
super("JIDX");
setBounds(300,100,300,200);
setLayout(new GridLayout(2,1));
b_ok=new JButton("OK");
JPanel p1;
p1=new JPanel();
JLabel l1=new JLabel();
JLabel l2=new JLabel();
JPanel p2=new JPanel();
p2.setBackground(Color.lightGray);
p2.setLayout(new GridLayout(1,3));
JLabel l3=new JLabel();
JLabel l4=new JLabel();
p2.add(l3);
p2.add(b_ok);
p2.add(l4);
p1.setLayout(new GridLayout(3,1));
p1.add(l1);
p1.add(p2);
p1.add(l2);
l_msg=new JLabel("",JLabel.CENTER);
add(l_msg);
add(p1);
b_ok.addActionListener(this);
setVisible(false);
addWindowListener(new WindowAdapter()
{public void windowClosing(WindowEvent e)
{setVisible(false);}
}
);
}
/**
*
* @param s The prompt message.
*/
public void show(String s)
{
l_msg.setText(s);
setVisible(true);
}
/**
* Listen to button OK's action.
*/
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==b_ok)
{
setVisible(false);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -