• 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

JOptionPane buttons don't seem to work.

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm trying to create a JOptionPane with yes and no options asking whether the person wishes to go into full screen mode or not. When the person clicks on yes, full screen mode should be set, but it's not. If I were to click on no, then it would do the correct thing. When I click on yes, it goes straight to normal screen. I'm not sure why and everything seems correct. Here's the Main class.

And the GameFrame constructor.

The isFullScreen boolean has a setter and getter for it, so that's where setFullScreen(boolean isFullScreen) comes into play. I don't see anything wrong with it if I'm setting the boolean to make it full screen or not and then setting the display mode for it. Help is appreciated. Thanks.
 
Sheriff
Posts: 22781
131
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
Are you sure it's the JOptionPane that isn't working? Try adding some System.out.println statements in your if-else block. My guess is that the error is located elsewhere (like GameFrame.runFullScreen).
 
Josh Rodrigues
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I fixed it. Seems like it wouldn't take the setter method:

Had to change it to:

Thanks anyway.
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Josh Rodrigues wrote:I fixed it. Seems like it wouldn't take the setter method:



Great!

Your posts sounds like you're not quite sure why this is. It's because a local variable always hides or "shadows" a member variable of the same name; what your first version is doing is assigning the value of the parameter to the parameter itself. Using the class name -- or "this" in a setter for an instance variable -- is always necessary if you use the same name for the parameter as for the member variable.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic