File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes GWT and the fly likes Need help on implementing a ClickHandler in a GWT composite widget Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » GWT
Bookmark "Need help on implementing a ClickHandler in a GWT composite widget" Watch "Need help on implementing a ClickHandler in a GWT composite widget" New topic
Author

Need help on implementing a ClickHandler in a GWT composite widget

Tapani Vuoripuomi
Greenhorn

Joined: Feb 13, 2012
Posts: 2
Have been trying all day to follow the instructions given in article:
http://www.gwtsushi.info/2010/08/four-easy-steps-to-implementing.html

but cannot get it to work.

Could someone explain what I'm doing wrong?

My code is as follows:

public class CompositeEventTest implements EntryPoint {
/**
* This is the entry point method.
*/
@Override
public void onModuleLoad() {
VerticalPanel vp = new VerticalPanel();
final Label lblMessage = new Label();
EventObject eventObject = new EventObject();
eventObject.addClickHandler(new ClickHandler() {

@Override
public void onClick(ClickEvent arg0) {
lblMessage.setText("You clicked the composite");

}

});

vp.add(eventObject);
vp.add(lblMessage);

RootPanel.get().add(vp, 10, 10);
}
}

and my composite:

public class EventObject extends Composite implements HasClickHandlers {

private final VerticalPanel mainPanel = new VerticalPanel();

@Override
public HandlerRegistration addClickHandler(ClickHandler handler) {
return addHandler(handler, ClickEvent.getType());
}

@UiHandler("EventObject")
void doClick(ClickEvent e) {
this.fireEvent(e);
}

public EventObject() {
Button btnClick = new Button("Button");
mainPanel.add(btnClick);
mainPanel.setPixelSize(100, 100);
mainPanel.setBorderWidth(3);

// All composites must call initWidget() in their constructors.
initWidget(mainPanel);
}
}

nothing happens when I'm clicking within the border of the mainpanel, why?

Regards
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Need help on implementing a ClickHandler in a GWT composite widget