Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Java question
#1
So im not great when it comes to GUI related things in Java, i've basically created a program that is a panel with 2 text boxes for 1 number each, and 2 buttons, one to wipe the text boxes clear (reset) and one to add the numbers. But im not sure how to retrieve each text box individually, so I cant get the values to add, or even set the destination to wipe, how do I go about this?
Reply
#2
Deviant Wrote:So im not great when it comes to GUI related things in Java, i've basically created a program that is a panel with 2 text boxes for 1 number each, and 2 buttons, one to wipe the text boxes clear (reset) and one to add the numbers. But im not sure how to retrieve each text box individually, so I cant get the values to add, or even set the destination to wipe, how do I go about this?
I've never done a GUI in Java, but I assume the textbox class has a getText() and a setText(String) method or something similarly named.
Reply
#3
Oh oops, didn't see this thread yesterday

I just had a look myself in the api. I'm assuming you are talking about TextArea.

There are setText and getText methods. However, they are in the inherited methods list (Inherited from TextComponent). The thing I find the worst when GUI programming in Java is the fact that half the methods are shown in a tiny little box called "Inherited methods". I'm guessing that you had trouble finding it because of that? Sad
It wouldn't just be a problem with GUI's though. Basically any class where a lot of its functionality is inherited Sad
Reply
#4
Just out of curiosity, what IDE are you using?
Reply
#5
For some reason getText reads it as a string, and I need it to be an int
Reply
#6
Deviant Wrote:For some reason getText reads it as a string, and I need it to be an int
Of course it's a string, it's text. You need to convert it with Integer.parseInt(String).
Reply
#7
Oh dur, its all good now, thanks.
Reply


Forum Jump:


Users browsing this thread: