This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Blanking out a button if they do not have enough funds in their bank. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Blanking out a button if they do not have enough funds in their bank." Watch "Blanking out a button if they do not have enough funds in their bank." New topic
Author

Blanking out a button if they do not have enough funds in their bank.

Brian O'Connor
Greenhorn

Joined: Aug 15, 2011
Posts: 15
Hey guys, im new to java and am wanting to disable a button say "20" if they do not have enough funds in their bank. I have had a shot at it but i keep getting "operator cannot be applied to java.lang.string,double. I'm pretty sure im missing something simple here.. =(





Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

Yes, the simple thing you missed was to tell us which of those 400 lines of code produced that error message. I wouldn't expect anybody to examine the whole lot carefully to figure that out, when you could just tell us.
Brian O'Connor
Greenhorn

Joined: Aug 15, 2011
Posts: 15
Sorry, found on line 88.

double currentBalance=
(new Double (atmData.getBalance())).doubleValue();
if (input <= currentBalance) {
au20Button.setEnabled(false);
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10426
    
    8

Hint:
Can you compare apples and oranges? String and double? Windoze and Mac?


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Brian O'Connor
Greenhorn

Joined: Aug 15, 2011
Posts: 15
Yeah, im only new to Java so i dont have alot of knowledge, but how do i go about rectifying this issue? do you convert the string or what?
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10426
    
    8

Convert the String to double and then compare. Hint:Check out the Double constructor.
Brian O'Connor
Greenhorn

Joined: Aug 15, 2011
Posts: 15
So this compiles but it's not blanking out the buttons.

Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10426
    
    8

So what's the value of currentBalance?
Brian O'Connor
Greenhorn

Joined: Aug 15, 2011
Posts: 15
$100 by default
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10426
    
    8

I would suggest using
to check what actual value you are getting.
Brian O'Connor
Greenhorn

Joined: Aug 15, 2011
Posts: 15
Ok just tried that and it is working, when i withdraw $20 the console produces $80.
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10426
    
    8

And the 20 and 50 buttons are getting disabled?
Brian O'Connor
Greenhorn

Joined: Aug 15, 2011
Posts: 15
Did you mean if they are disabling if the balance is under the withdraw amount? then still no =(
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10426
    
    8

I think it would help if you post your SSCCE code, which we can download and run in our environment. Please do take out time to click on the SSCCE link to find out what it really means.
Brian O'Connor
Greenhorn

Joined: Aug 15, 2011
Posts: 15
Ok so you would like me to upload all of the classes and other information?
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10426
    
    8

Maneesh Godbole wrote:Please do take out time to click on the SSCCE link to find out what it really means.

Did you do this?
http://sscce.org/
 
GeeCON Prague 2014
 
subject: Blanking out a button if they do not have enough funds in their bank.