Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / December 2003

Tip: Looking for answers? Try searching our database.

using a value from a textBox

Thread view: 
Sunny - 30 Nov 2003 19:05 GMT
Evening all, just wondering. Im currently using an int, int i = 100; this
sets the timer to count down from, all works fine..
But now im trying to change the int i to a value the user inputs via a
textbox. Cant seem to figure it out, trying things like, textBox.getText()
just cant get to grasps with it, any ideas?

Cheers
Lee Weiner - 30 Nov 2003 19:36 GMT
>Evening all, just wondering. Im currently using an int, int i = 100; this
>sets the timer to count down from, all works fine..
[quoted text clipped - 3 lines]
>
>Cheers

getText() returns a String. You have to convert it to an int to assign it to
your variable.

       int i = Interger.parseInt( textBox.getText() );

Lee Weiner
lee AT leeweiner DOT org
Andrew Marshall - 01 Dec 2003 04:56 GMT
> Evening all, just wondering. Im currently using an int, int i = 100; this
> sets the timer to count down from, all works fine..
[quoted text clipped - 3 lines]
>
> Cheers

If you type the text into the field, you need to have some sort of
listener to a button, that when pressed, calls: textBox.getText() and then
parses it as an integer. you can then take that and do whatever you want
to it.

Andrew.
Sunny - 01 Dec 2003 18:34 GMT
> > Evening all, just wondering. Im currently using an int, int i = 100; this
> > sets the timer to count down from, all works fine..
[quoted text clipped - 10 lines]
>
> Andrew.

Cheers, for further reference, this is the code i used:
##########################
int t = 0;

 t = Integer.parseInt( txtField.getText() );
       timer.start();
##########################
Works fine :)


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.