This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
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
Author

A frame not showing up

Hans vogn
Ranch Hand

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

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
Bartender

Joined: May 03, 2008
Posts: 4571
    
    5

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: http://aspose.com/file-tools
 
subject: A frame not showing up