display.getText() should be sufficient. You want a String, it's a String. /shrug
IF you want to validate that it's actually a double, the easiest way is to wrap a call to parseDouble in a try block. Use the catch block to reject the offered value (if you're in the catch block, it's not a double, so return to the user for another try) otherwise discard the parsed value and continue.
This post has been edited by jon.kiparsky: 05 December 2012 - 02:57 PM
i'm attempting to make a GUI-designed calculator, but when ever i do a simple equation, "2 + 2" = "0" but then when i try to go to the next equation, it doesn't clear like it's supposed to or the numbers that click add afterwards, as well as, i can't do numbers over "9 + 9" either
I can add the code and/or attach the program, if you want
You can probably come up with better variable names but this is the best I can do without more context. As others have pointed out, this middle line does nothing (which is more obvious in my code than in yours):
String rawValue = display.getText();
double result = Double.parseDouble(rawValue);
Now you can start to inspect it. You can either set breakpoints in your debugger or insert a couple of println into your code to show the values of these two variables. Are they what you expected?
Edit: Is this piece of code even called? (a more common bug than you might think! Prove it with breakpoints/println)