问题
How to I make a hyperlink that functions as a button? Or how do I make a button that looks like a hyperlink?
回答1:
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");
回答2:
As of GWT 1.5, there is an Anchor widget that should do what you want.
回答3:
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.
来源:https://stackoverflow.com/questions/1076616/gwt-link-button