• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

Need help on implementing a ClickHandler in a GWT composite widget

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Yes, my master! Here is the tiny ad you asked for:
Enterprise-grade Excel API for Java
https://products.aspose.com/cells/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!