Results 1 to 10 of 10
Thread: setText() doesn't work
- 03-21-2012, 12:12 PM #1
Member
- Join Date
- Mar 2012
- Posts
- 4
- Rep Power
- 0
setText() doesn't work
I'm unable to change the text of a label by the command .setText() within my RootPanel.
Basicly, within the public void onModuleLoad() { ... } i have my RootPanel, buttons and label.
It doesn't change the text when used within the Click Event.
I'm unable to create a method within my onModuleLoad() to change the label text as well.
I cannot refer to the label variable outside of the onModuleLoad().
Appreciate any help.
- 03-21-2012, 12:15 PM #2
Moderator
- Join Date
- Apr 2009
- Posts
- 10,484
- Rep Power
- 16
Re: setText() doesn't work
Without code it's going to be hard to say.
And don't forget to use [code] tags [/code].Please do not ask for code as refusal often offends.
- 03-22-2012, 11:47 AM #3
Member
- Join Date
- Mar 2012
- Posts
- 4
- Rep Power
- 0
Re: setText() doesn't work
The code can be executed. But the text doesn't change. Neither if we do an System.out.println(lblStr.getText());Java Code:package com.mycompany.project.client; public class Main implements EntryPoint { public void onModuleLoad() { RootPanel rootPanel = RootPanel.get(); final Label lblStr = new Label("Size"); rootPanel.add(lblStr, 188, 10); final RadioButton rdbtnSmall = new RadioButton("new name", "Small"); rdbtnSmall.setValue(true); rootPanel.add(rdbtnSmall, 5, 10); rdbtnSmall.setSize("66px", "19px"); rdbtnSmall.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { lblStr.setText("Small"); } }); } }
- 03-22-2012, 12:43 PM #4
Moderator
- Join Date
- Apr 2009
- Posts
- 10,484
- Rep Power
- 16
Re: setText() doesn't work
What GUI are you using here?
Is this AWT?Please do not ask for code as refusal often offends.
- 03-22-2012, 01:04 PM #5
Senior Member
- Join Date
- Jun 2007
- Location
- Bali, Indonesia
- Posts
- 697
- Rep Power
- 6
Re: setText() doesn't work
From the code snippet it's using the Google GWT.
Website: Learn Java by Examples
- 03-22-2012, 01:22 PM #6
Member
- Join Date
- Mar 2012
- Posts
- 4
- Rep Power
- 0
Re: setText() doesn't work
Yeah we're using Google GWT.
- 03-22-2012, 01:55 PM #7
Moderator
- Join Date
- Apr 2009
- Posts
- 10,484
- Rep Power
- 16
Re: setText() doesn't work
You don't think that it might have been an idea to mention it?
Please do not ask for code as refusal often offends.
- 03-22-2012, 02:01 PM #8
Senior Member
- Join Date
- Jun 2007
- Location
- Bali, Indonesia
- Posts
- 697
- Rep Power
- 6
Re: setText() doesn't work
The code snippet is perfectly fine in for me. There no problem in setting the label text using the setText() method. Did it produce any error exception there?
Website: Learn Java by Examples
- 03-22-2012, 02:20 PM #9
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,604
- Blog Entries
- 7
- Rep Power
- 17
- 03-22-2012, 02:37 PM #10
Member
- Join Date
- Mar 2012
- Posts
- 4
- Rep Power
- 0
Similar Threads
-
Why doesn't this work?
By mailman in forum Java AppletsReplies: 5Last Post: 01-10-2012, 01:01 PM -
Jar doesn't work
By mad72584 in forum New To JavaReplies: 35Last Post: 08-07-2011, 05:22 PM -
why this doesn't work?
By hitesh_public in forum New To JavaReplies: 5Last Post: 08-09-2010, 08:07 AM -
Why doesn't this work?
By Corder10 in forum New To JavaReplies: 1Last Post: 07-04-2009, 10:33 PM -
Why doesn't my loop work?
By d0nmin0 in forum Advanced JavaReplies: 8Last Post: 05-26-2008, 06:56 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks