Meaningless Drivel is fun!
The moose likes Swing / AWT / SWT and the fly likes A frame not showing up Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "A frame not showing up" Watch "A frame not showing up" New topic

A frame not showing up

Hans vogn
Ranch Hand

Joined: Feb 04, 2009
Posts: 46

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

Joined: Feb 24, 2011
Posts: 495

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

“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” (Mosher's Law of Software Engineering)
“If debugging is the process of removing bugs, then programming must be the process of putting them in.” (Edsger Dijkstra)
Hans vogn
Ranch Hand

Joined: Feb 04, 2009
Posts: 46
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

Joined: May 03, 2008
Posts: 5115

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.

luck, db
There are no new questions, but there may be new answers.
I agree. Here's the link:
subject: A frame not showing up
It's not a secret anymore!