实验五 图形用户界面(15)
发布时间:2021-06-07
发布时间:2021-06-07
p2.add(exit); p2.add(dialog);
exit.addActionListener(this);
dialog.addActionListener(this);
pack();
show();
//setVisible(true);}
public static void main(String args[]) {
new LX5_10();}
public void actionPerformed(ActionEvent e) {
if (e.getSource()==exit)
System.exit(0);
else {
MyDialog dlg=new MyDialog(this, true);
dlg.show();}
}
class MyDialog extends Dialog implements ActionListener {
Label label1=new Label("请输入行数");
Label label2=new Label("请输入列数");
TextField rows=new TextField(50);
TextField columns=new TextField(50);
Button OK=new Button("确定");
Button Cancel=new Button("取消");
MyDialog(LX5_10 parent, boolean modal) {
super(parent,modal);
setTitle("自定义对话框");
setSize(260,140);
setResizable(false);
setLayout(null);
add(label1);
add(label2);
label1.setBounds(50,30,65,20);
label2.setBounds(50,60,65,20);
add(rows);
add(columns);
rows.setText(Integer.toString(ta.getRows()));
columns.setText(Integer.toString(ta.getColumns()));
rows.setBounds(120,30,90,20);
columns.setBounds(120,60,90,20);
add(OK);
add(Cancel);
OK.setBounds(60,100,60,25);
Cancel.setBounds(140,100,60,25);
OK.addActionListener(this);
Cancel.addActionListener(this);}
上一篇:钣金加工的识图方法
下一篇:美方-在线气体检测系统技方案