简体   繁体   中英

Popup existing Jframe when clicking button in another Jframe

我正在使用netbeans在JAVA GUI项目中工作,我刚刚创建了Jframe并在其上放置了一个按钮,我还创建了另一个JFrame并添加了许多标签,我问当我单击第一个按钮时第二个JFrame怎么出现? J框架

button.addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
        new SecondFrame().setVisible(true);
        FirstFrame.this.dispose(); // if you want the first frame to close
    }

Check out How to Write an Action Listener for more information.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM