问答题
注意:请勿改动main()主方法和其他已有语句内容,仅在横线处填入适当语句。
Import __________;
import java.awt.event.*;
import javax.swing.*;
public class Example2_2 extends Frame implements ActionListener
{
private Dialog dlg;
private Button but;
public static void main(String argv[])
{
Example2_2 f = new Example2_2("Example2_2");
Panel pan=new Panel();
}
public Example2_2(String str)
{
super(str);
setSize(200,200);
setLayout (new FlowLayout ());
but = new Button("显示 Dialog");
add (but);
but. addActionListener (this);
dlg = new Dialog(______,"Dialog",false);
dlg.add("Center",new Label("这是一个练习,希望大家都能考个好成绩"));
dlg.setSize(300,100);
setVisible (true);
addWindowListener (new WindowAdapter ( ) {
public void windowClosing(WindowEvent e){
System.exit (0);
}
});
dlg.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit (0);
}
});
}
public void actionPerformed(ActionEvent e){
dlg. setVisible(true); //显示介面
}
}