| Thread Closed |
Java GUI |
Share Thread |
| Nov27-07, 06:51 PM | #1 |
|
|
Java GUI
When using GUIs, you can enter an integer or a double into an input dialog box, then you can set a variable equal to the input such as below:
int variable = Integer.parseInt(String name); or double variable = Double.parseDouble(String name); If I enter a string into the dialog box, and I want to set a variable of the string type equal to that input, what code can I use that's similar to the code above? I can't seem to find anything in my text book. I'm looking for something like: String variable = String.parseString(String name); Any help is appreciated. |
| Nov27-07, 10:41 PM | #2 |
|
|
I'm not totally sure I understand the question, but I'm pretty sure that what you want is the
object.toString() method. ANY object in Java should have a toString() method (although sometimes it will not return what you expect) and so it is analogous to the Type.parse(object) methods.. |
| Nov28-07, 06:39 AM | #3 |
|
|
I'm no expert on Java but I would think that the reason you NEED "Integer.parseInt(String name)" and "Double.parseDouble(String name)" is to change a string to an integer or double. You don't NEED a function to change a string to a string!
Just "String variable= name;" should work. |
| Nov28-07, 07:04 PM | #4 |
|
|
Java GUI
Thank you for the replies.
I think HallsofIvy hit the nail on the head. I was doing it assbackwards. I should have imported a GUI package, and used the methods within that package to display a string. |
| Thread Closed |
Similar discussions for: Java GUI
|
||||
| Thread | Forum | Replies | ||
| java q | Computing & Technology | 3 | ||
| new to java | Programming & Comp Sci | 7 | ||
| Java help | Computing & Technology | 15 | ||
| Help in Java 3D | Computing & Technology | 0 | ||
| Java | Introductory Physics Homework | 13 | ||