English 中文(简体)
Refresh the UI in gwt
原标题:

I have created some custom composite widget, which listens to an events (in my case loginEvent). Once the event is caught the state of the widget changes so as the way it should look (in my case I would like to change one of the icons to a signal that the user is logged in).

However, after the event is caught, can I make the widget draw itself again according to the new state?

I am pretty new to GWT so be gentle and please elaborate...

问题回答

There is many ways to do this. This example shows how to show Login/Logout and toggle visibility when a user logged in event is raised.

public class LoginLogoutWidget extends Compostite {
    private final Anchor m_loginLink;
    private final Anchor m_logoutLink;

    public LoginLogoutWidget() {

        m_loginLink = new Anchor("Login");
        //Register event handlers etc

        m_logoutLink = new Anchor("Logout");
        //Register event handlers etc

        HorizontalPanel hp = new HorizontalPanel();

        hp.add(m_loginLink);
        hp.add(m_logoutLink);

        initWidget(hp);

        //Default login visible, and logout invisible
        m_logoutLink.setVisible(false);
    }

    public void onLoginEvent(boolean loggedIn) {        
        m_loginLink.setVisible(!loggedIn);
        m_logoutLink.setVisible(loggedIn);  
    }
}




相关问题
How to start to create an application GUI using C#?

HI! I am new to C# and plan to use it for my application GUI. I am trying to make my GUI similar to SPSS:http://www.spss.com/images/08/statistics_screens/ez_rfm-big.jpg Is this easy in C#? Is there ...

Automatic height of edit box

My shoes application has three items stacked on top of each other (with a stack, of course), in order: A banner An edit box Two buttons in a flow What I want to do is have the banner stay at it s ...

Search by using the keyboard in a list/grid - algorithm

I need to implement a custom search in a grid and I would like to find some user interface guidelines that explain the standard way to implement it. I mean this kind of search that is initiated by ...

UI And TcpClient Issue in vb.net

I m having some problems with a small ircbot i m writing. Basically I connect to the server using a tcpclient in a seperate class, which also runs on its own thread. I want to display the server text ...

UI Convention: Shortcut key for application exit? [closed]

Is there a convention for the shortcut keys for application exit? Some applications uses Alt+X some others use Ctrl+ X and Ctrl+Q. Applications like FF and IE doesnot assign a shortcut at all. So is ...

热门标签