File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes Navigating between two JFrame in Java Swing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Navigating between two JFrame in Java Swing" Watch "Navigating between two JFrame in Java Swing" New topic
Author

Navigating between two JFrame in Java Swing

Randy Miller
Ranch Hand

Joined: Feb 13, 2012
Posts: 44
Hi guys!

Right now I am trying to open a new JFrame as soon as I hit the corresponding button on my current active GUI.But somehow, the Frame won´t be displayed,just the titlebar without title and all the components. If I start the class/JFrame solely,it displays perfectly.Just in combination with the "main" GUI, I just won´t get the second GUI to display correctly.

Here´s what I got so far:



So THIS is the class/frame I want to call in my actionPerformed-method in my Main Class, called MyFrame(). Of course this class right here also has a actionPerformed()-method for its buttons and two other methods which are not important for navigation purposes.
Can anyone help?I don´t know,how to properly open this frame!?

What I tried so far is something like this inside the actionPerformed()-method of the MyFrame-class:


But that just won´t do the trick...

Greetings,

Randy
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36514
    
  16
Why are you using two frames? Why are you not using a dialogue?
Randy Miller
Ranch Hand

Joined: Feb 13, 2012
Posts: 44
Hi Ritchie!

Pretty simple: Cause the main frame doesn´t have anything to do with the second frame I want to open ;)
Functionally that is ;)
I just want to keep these two frames pretty much non-depending on each other ;)
And I think, a simple dialog wouldn´t do the trick for me ;)
But if you got an easier idea,just fire it at me ;)
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36514
    
  16
That sounds like two independent apps to me.
Randy Miller
Ranch Hand

Joined: Feb 13, 2012
Posts: 44
It is,sort of ;)
The additional frame adds new functions to the main frame ;)
And of course,the second frame does some calculating(better say parsing),which means,a normal user dialog wouldn´t be enough to do the trick,right?
Now,how can I get this stuff to work?
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36514
    
  16
You oughtn’t to be parsing in a Frame. A Frame is a display, and you should have a separate parser class.
Randy Miller
Ranch Hand

Joined: Feb 13, 2012
Posts: 44
Hi guys!

Thanks for your help so far ;)
I solved the problem already
Wasn´t too hard though ;)
Just like you suggested,I seperated the logic from my frame and just used the frame for displaying purposes.
And now,finally,the navigation works just like a machine ;)
Thanks to all of you
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36514
    
  16
Well done
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Navigating between two JFrame in Java Swing
 
Similar Threads
Regarding layouts
I cant seem to fix this compile error !! please help me
Layout challenge.
Not working JScrollPane
Best Layout for Simple Forms?