Win a copy of Zero to AI - A non-technical, hype-free guide to prospering in the AI era this week in the Artificial Intelligence and Machine Learning 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
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

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
 
Pay attention! Tiny ad!
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
reply
    Bookmark Topic Watch Topic
  • New Topic