如何用java点击一个本地程序弹出窗口中的确认按钮

如题所述

import java.awt.Button;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JFrame;
public class Demo {
public static void main(String[] args) {
Demo demo = new Demo();
demo.run();
}

public void run() {
JFrame frame = new JFrame("title1");
frame.setLayout(null);
frame.setBounds(10, 10, 500, 300);

Button button = new Button("click");
button.setBounds(15, 15, 200, 100);
frame.add(button);
frame.setVisible(true);

button.addActionListener(new ActionListener() {

@Override
public void actionPerformed(ActionEvent e) {
JFrame frame = new JFrame("title2");
frame.setLayout(null);
frame.setBounds(20, 20, 300, 100);
frame.setVisible(true);
}
});
}
}
哪里不懂可以追问,很简陋的程序哈。
温馨提示:内容为网友见解,仅供参考
无其他回答
相似回答