Get value from TextField after creating it on Codename one designer

478 views
Skip to first unread message

nas...@gmail.com

unread,
Sep 19, 2014, 5:49:55 PM9/19/14
to codenameone...@googlegroups.com
I am using IDE: NetBeans. I have created a text field using Codename one designer. To get the value typed into the text field I named "NumTwo" I used the following java code which always works for my previous projects:

String num1 = Num1.getText();

Am getting an error that "cannot find symbol: variable Num1" . How am I supposed to declare the variable from the Codename one designer into NetBeans?

Please help...

nas...@gmail.com

unread,
Sep 19, 2014, 6:27:48 PM9/19/14
to codenameone...@googlegroups.com, nas...@gmail.com
Anyone at least point me the right direction if maybe my question is too amateur for this forum so I may dig up my answer for myself from there.

Joshua Aroke

unread,
Sep 19, 2014, 10:00:38 PM9/19/14
to codenameone...@googlegroups.com, nas...@gmail.com
You can always get an instance of currently showing component you added with codenameone designer like this

TextField textF = findNum1();

so you can have

String num1 = findNum1().getText();

there is also

findNum1(Component root)
 This take a parent container or form of textfield as argument. Read more in the developers' guide

Good Luck

Shai Almog

unread,
Sep 20, 2014, 12:24:00 AM9/20/14
to codenameone...@googlegroups.com, nas...@gmail.com
FYI use findNum1(cmp) rather than findNum1() which might lead to undesired consequences.
Reply all
Reply to author
Forward
0 new messages