代码:
//MsgDlg.java package java_class.Guess; import java.awt.Button; import java.awt.Frame; import java.awt.Label; import java.awt.Panel; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; class MsgDlg extends Frame implements ActionListener { Label label = new Label(); public MsgDlg(String strMsg) { super(); setResizable(false); setTitle("猜的结果"); Panel p = new Panel(); add(p); p.add(label); label.setText(strMsg); setSize(200, 60); setLocation( (int)java.awt.Toolkit.getDefaultToolkit().getScreenSize().width/2-100, (int)java.awt.Toolkit.getDefaultToolkit().getScreenSize().height/2-50); Button btOk = new Button("确定"); btOk.addActionListener(this); p.add(btOk); setVisible(true); } public void actionPerformed(ActionEvent evt) { this.dispose(); } }
近期评论