Results 1 to 10 of 10
  1. #1
    Ratsha is offline Member
    Join Date
    Mar 2012
    Posts
    4
    Rep Power
    0

    Default 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.

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,817
    Rep Power
    19

    Default 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.

    ** This space for rent **

  3. #3
    Ratsha is offline Member
    Join Date
    Mar 2012
    Posts
    4
    Rep Power
    0

    Default Re: setText() doesn't work

    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");
          }
       });
    
       }
    }
    The code can be executed. But the text doesn't change. Neither if we do an System.out.println(lblStr.getText());

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,817
    Rep Power
    19

    Default Re: setText() doesn't work

    What GUI are you using here?
    Is this AWT?
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  5. #5
    wsaryada is offline Senior Member
    Join Date
    Jun 2007
    Location
    Bali, Indonesia
    Posts
    757
    Rep Power
    8

    Default Re: setText() doesn't work

    From the code snippet it's using the Google GWT.

  6. #6
    Ratsha is offline Member
    Join Date
    Mar 2012
    Posts
    4
    Rep Power
    0

    Default Re: setText() doesn't work

    Yeah we're using Google GWT.

  7. #7
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,817
    Rep Power
    19

    Default 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.

    ** This space for rent **

  8. #8
    wsaryada is offline Senior Member
    Join Date
    Jun 2007
    Location
    Bali, Indonesia
    Posts
    757
    Rep Power
    8

    Default 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?

  9. #9
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,352
    Blog Entries
    7
    Rep Power
    20

    Default Re: setText() doesn't work

    Quote Originally Posted by Tolls View Post
    You don't think that it might have been an idea to mention it?
    Of couse not; this is a guessing game remember?

    kind regards,

    Jos ;-)
    cenosillicaphobia: the fear for an empty beer glass

  10. #10
    Ratsha is offline Member
    Join Date
    Mar 2012
    Posts
    4
    Rep Power
    0

    Default Re: setText() doesn't work

    I didn't knew it was relevent to the problem. The code doesn't produce any error. The code can be executed but doesn't change the text.

Similar Threads

  1. Why doesn't this work?
    By mailman in forum Java Applets
    Replies: 5
    Last Post: 01-10-2012, 01:01 PM
  2. Jar doesn't work
    By mad72584 in forum New To Java
    Replies: 35
    Last Post: 08-07-2011, 05:22 PM
  3. why this doesn't work?
    By hitesh_public in forum New To Java
    Replies: 5
    Last Post: 08-09-2010, 08:07 AM
  4. Why doesn't this work?
    By Corder10 in forum New To Java
    Replies: 1
    Last Post: 07-04-2009, 10:33 PM
  5. Why doesn't my loop work?
    By d0nmin0 in forum Advanced Java
    Replies: 8
    Last Post: 05-26-2008, 06:56 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •