0

I have this code:

Tela2 t= new Tela2(); //JFrame

File f= jFileChooser1.getSelectedFile() ;
if(f.getName().endsWith("detailed.txt")){
    this.dispose();// close this Jframe
    t.setVisible(true);//open a new one
    p.addAnalise(f); 
}

the "t" JFrame shows up but the components don't show until the method p.addAnalise() is finished, can someone help me?

Hovercraft Full Of Eels
  • 283,665
  • 25
  • 256
  • 373
  • 2
    Post a [mcve] if you want people to help you – Reimeus Aug 24 '17 at 12:22
  • Please provide a [mcve], or at least the code of the `Tela2` class, and the `addAnalise` method . – Arnaud Aug 24 '17 at 12:22
  • 1
    As the others already said, without more information we only can guess. My guess would be that you're either only adding components (or making them visible) at the end of the method or (more likely) blocking the event dispatch thread in that method. – Thomas Aug 24 '17 at 12:26
  • As all the above folks state, your question isn't answerable in its present form without guessing. Also please have a look at [The Use of Multiple JFrames, Good/Bad Practice?](http://stackoverflow.com/questions/9554636) to see why your overall plan to swap JFrames may not be the best, and how you could improve up on it. – Hovercraft Full Of Eels Aug 24 '17 at 12:30
  • And yes, likely `addAnalise(f)` is calling a long-running bit of code, code that should be run in a background thread such as within a SwingWorker. Please also read: [Lesson: Concurrency in Swing](http://docs.oracle.com/javase/tutorial/uiswing/concurrency/) – Hovercraft Full Of Eels Aug 24 '17 at 12:31
  • sorry for not posting the rest of the code, but the threads solved my problems, thanks. Anyway, i will try to post more especific and detailed questions next time. – William Silveira Aug 24 '17 at 12:58

0 Answers0