tags:

views:

3614

answers:

4
+4  Q: 

GWT link button

How to I make a hyperlink that functions as a button? Or how do I make a button that looks like a hyperlink?

+4  A: 

One easy way is to use the Label class. Just create a new label and add a ClickHandler to it. You can then style it however you want using CSS:

Label lbl = new Label("Hello");
lbl.addClickHandler(...);
lbl.setStyleName("hyperlink_style_label");
rustyshelf
I have tried the Anchor approach, but for some reason the Anchor in GWT triggers a Window.ClosingEvent in IE. Not sure what's happening there. However, doing it this way with the clickHandler worked just fine in IE.
stuff22
+7  A: 

As of GWT 1.5, there is an Anchor widget that should do what you want: http://google-web-toolkit.googlecode.com/svn/javadoc/1.5/com/google/gwt/user/client/ui/Anchor.html

Kelly Norton
A: 
A: 

I also found you can use the anchor class. add a click event and load the method you want as a new page. Inside the page clear the root or other panels you want using the clear() method eg. Rootpanel.get("root panel name").clear();

I wrote the example up and gave an example if you want to check it out. Hope this helps.

Colin Chambers