• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

How do I pass a frame into another class?

 
Ranch Hand
Posts: 171
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
try using internal frames...

http://java.sun.com/docs/books/tutorial/uiswing/components/internalframe.html
 
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 22683
128
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
We usually only want to see an SSCCE.
 
There's a way to do it better - find it. -Edison. A better tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic