aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes JOptionPane buttons don't seem to work. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JOptionPane buttons don Watch "JOptionPane buttons don New topic
Author

JOptionPane buttons don't seem to work.

Josh Rodrigues
Greenhorn

Joined: Apr 14, 2010
Posts: 17
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.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19543
    
  16

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).


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Josh Rodrigues
Greenhorn

Joined: Apr 14, 2010
Posts: 17
I fixed it. Seems like it wouldn't take the setter method:

Had to change it to:

Thanks anyway.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24166
    
  30

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.


[Jess in Action][AskingGoodQuestions]
 
Consider Paul's rocket mass heater.
 
subject: JOptionPane buttons don't seem to work.
 
Similar Threads
Weird flashy Buffer thing in Swing..I think. Maybe
Developing Games In Java chapter 2 example not doing as i would have expected
Images don't painting
Pong
Drawing An Image In Full-Screen