• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

A frame not showing up

 
Hans vogn
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I have recently written an application that uses two JFrames. I post this in the "Java in General" because I don't know what kind of issue this is?

The program runs perfectly when i start it from cmd, but when i pack a .jar file and run that, it only shows one of the two JFrames??

The code that contains the second, and not visible frame is:



It's an inner class of the main class, can cause any issueses about showing it in runtime?

Thanks in advance
 
john price
Ranch Hand
Posts: 495
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is a post in the Swing forum. I slightly modified your code. It runs fine. Maybe you never call CtlPanel to run?

John Price

 
Hans vogn
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmmm... I've been playing around a little, and i have moved the initializing of the second frame (the CtlPanel code block) into the same block that initalizes the first frame. Yet, the second does not show up.

It's the same, when I run the program from cmd (not in the jar just from .class file) works just fine, but if i double click the .jar file, only one frame shows up.

I did find out something interesting, lets call the first frame frame1 and the second frame2, if i do like this:



it shows omly frame1, but if i do this:



It shows nothing!? Thread keeps running, no exeptions and no frames???

Is there something you can do from a class, that can't be done from .jar files? I'm thinking that perhaps JVM will not allow mulipte JFrames showing up quikly after each other to prevent those anoying applictions that opens 100 frames in a second?
 
Darryl Burke
Bartender
Posts: 5125
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First off, respect Swing's single threaded rule and call all Swing constructors and methods on the EDT, using SwingUtilities#invokeLater(...). Post the updated code if the problem persists.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic