MichalB
MichalB

Reputation: 3341

How to open new JFrame when clicking JButton?

I have a simple problem with opening a new JFrame called focalSumFrame while clicking on JButton called focalSum. I am working in netBeans IDE. My code looks like this:

private void focalSumActionPerformed(java.awt.event.ActionEvent evt) {                                         
    focalSumFrame.pack();
    focalSumFrame.setVisible(true);   
}

Upvotes: 2

Views: 5977

Answers (1)

Max
Max

Reputation: 6239

It's more efficent and easier to use JDialogs and/or CardLayout for alternative pages of your program. Creating other JFrames to use as your pop-ups is a very ineffective way to go about what you're trying to do.

JDialog Information

Card Layout Information

Upvotes: 4

Related Questions