Reputation: 4380
I'm using GWT 2.6.0 and I'm following the StockWatcher tutorial.
Simplified, this is my code:
private Button sendButton = new Button("send");
private VerticalPanel mainPanel = new VerticalPanel();
public void onModuleLoad(){
// this works
mainPanel.add(sendButton);
RootPanel.get("stockList").add(mainPanel);
// until I add a Click Handler:
sendButton.addClickHandler(event -> addStock());
}
private void addStock(){
//TODO: implement
}
The button is not rendered. However, if I remove the click handler, the button becomes visible.
I'm completely new to GWT and I'm wondering what I'm doing wrong here?
I'm using ant devmode
to run in development mode and I'm using Firefox 26.0.
Upvotes: 1
Views: 291
Reputation: 4104
It looks like that lamdas a java8 feature are not supported yet by GWT:
sendButton.addClickHandler(event -> addStock());
Here's how to add a click handler
Button b = new Button("Click Me");
b.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
// handle the click event
}
});
Upvotes: 1
Reputation: 116
I not sure, that gwt 2.6 supports java8 and lambdas. To be convinced of this, try to compile you project to javascript.
Java 7 is supported and is now the default. (This can be overridden using -sourceLevel 6) http://www.gwtproject.org/release-notes.html#Release_Notes_2_6_0
Upvotes: 3