wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes How do I pass a frame into another class? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How do I pass a frame into another class?" Watch "How do I pass a frame into another class?" New topic
Author

How do I pass a frame into another class?

Mike Lipay
Ranch Hand

Joined: Sep 11, 2007
Posts: 171
On line #271 I am trying to pass the frame into Title class so that it can open a JDialog, but I am stumped on how to pass the frame into the class.

Maya Naga
Ranch Hand

Joined: Nov 09, 2009
Posts: 79
try using internal frames...

http://java.sun.com/docs/books/tutorial/uiswing/components/internalframe.html
pete stein
Bartender

Joined: Feb 23, 2007
Posts: 1561
Part of the art of asking a question here is knowing what to add to your post and what not to ask. Your post contains a gabillion lines of irrelevant code, but doesn't contain enough description of the problem, and this may be why there's a significant delay in your getting a decent answer because who wants to slough through all that code, not even knowing what your problem is? Your code should just contain the absolute minimum required to show your problem, and if possible, compile without need of outside dependencies (such as VIM classes or whatnot).

For instance, this would show your problem:


Then you'd state that at the indicated line, the compiler complains that JDialog has no constructor that takes MainFrame.ButtonAction, String, boolean as parameters.

If you did this, we'd be able to tell you that the "this" in the JDialog constructor call refers to the ButtonAction class object not to the MainFrame class object, and to reference an outside class from an inner class, you need to qualify the this keyword with the outside class name. Thus "this" becomes "MainFrame.this":



Then you could use this information to change line 271 in your program from

to


Sorry about the lecture, but it was somewhat painful to go through all that code, and so if I can ease the suffering of others in the future, then I've done some good!

Also, if you read the FAQ on how to ask questions here, you'll see all this spelled out but perhaps in a better way. Happy coding!
Mike Lipay
Ranch Hand

Joined: Sep 11, 2007
Posts: 171
Thank you, and my apologies. In the past I've been asked to post the entire code that causes problems, when I've only posted a snippet, so I was trying to avoid that issue. I will try to do better next time.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19672
    
  18

We usually only want to see an SSCCE.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How do I pass a frame into another class?