Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How do I pass a frame into another class?

 
Mike Lipay
Ranch Hand
Posts: 171
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 79
 
pete stein
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 171
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20532
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We usually only want to see an SSCCE.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic