1

Before you say something, i know the implications of having more than one JFrame. I'm kinda delayed and i need to add the components manually.

So, i open a JFrame that i have designed with a button click:

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         

   JFrame DataCalc = new JFrame();
   DataCalc.setVisible(true); 
   DataCalc.setSize(500, 500);
   DataCalc.setLocationRelativeTo(null);   
}      

Then the JFrame shows up but doesn't show my components. I read that if i setVisible before adding components they won't show, but they're already there cause i designed them.

If i change my code and add the setSize and setLocation like the following code, nothing happens besides the JFrame opening.

public DataCalc() {
    this.setSize(500, 500);
    this.setLocationRelativeTo(null);
    initComponents();
}

Sry for the post, i'll edit my post if you need more info.

noidea
  • 184
  • 5
  • 22
  • 2
    1) See [The Use of Multiple JFrames, Good/Bad Practice?](http://stackoverflow.com/q/9554636/418556) 2) For better help sooner, post a [MCVE] or [Short, Self Contained, Correct Example](http://www.sscce.org/). – Andrew Thompson May 24 '16 at 15:41

1 Answers1

3
JFrame DataCalc = new JFrame();

Should be:

JFrame dataCalc = new DataCalc(); // use the CUSTOM frame!
Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433