This week's book giveaway is in the Reactive Progamming forum.
We're giving away four copies of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams and have Adam Davis on-line!
See this thread for details.
Win a copy of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams this week in the Reactive Progamming forum!
  • 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
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

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:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!