且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用弹出窗口将项目添加到数组列表

更新时间:2023-01-02 09:53:50

尝试,

JButton but = new JButton("Popup");
but.addActionListener(new ActionListener() {
 @Override
 public void actionPerformed(ActionEvent e) {
 final JPanel myPanel = new PopupPanel();// Create a separate class extends JPanel
     int result = JOptionPane.showConfirmDialog(null, myPanel,
          "Please Enter data into both boxes", JOptionPane.OK_CANCEL_OPTION);
            if (result == JOptionPane.OK_OPTION) {

            }
        }
    });