• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

More problems with my two frames

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I really appreciate the help I got from my last porblem, I got another
I open another frame with a CheckBoxMenuItem and that works, same with the closing. However, I need the CheckBoxMenuItem to become unchecked when you close the other frame by the x in the titlebar. This is the code I used.

This compiles, but when I try it, I get this exception and it doesn't work, any ideas?
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do you ever assign a value to the -

at the start of your ColorWindowAdapter?

If you never assign a value to it, you'll get a NullPointerException when you call unCheck() on it later.
 
Jeremy Jones
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I also meant to say that the unCheck is in the class of the other frame.
Plus, what do I need to do to not get the null exception, initialized the paintWindow to null and I still get it
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you initialize it to null, that's not going to prevent a *Null*PointerException...

You're going to have to pass a reference to an actual object of the MyPaint class that the paintWindow reference can point to. You can do this through either a constructor parameter, or through some kind of set method (or, if the ColorWindowAdapter is an inner class, you can access variables in the class containing ColorWindowAdapter). I would recommend simply passing a reference through an argument to the constructor, because then the ColorWindowAdapter created will always have a MyPaint object associated with it (unless you explicitly pass null to the constructor).

 
Ranch Hand
Posts: 286
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not sure if this would work since I don't see the rest of your code, but couldn't you just subclass the CheckBoxMenuItem and make it a window listener as well? Or make it your primary window listener if that checkbox is the way you open the other window. Then you just have it uncheck itself when the window says it is closing...
Chris
 
Jeremy Jones
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I figured it out, thanks anyway for trying to help
 
They gave me pumpkin ice cream. It was not pumpkin pie ice cream. Wiping my tongue on this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic