Hi, I am trying to create a simple header with caption and close button at the right end. I have created simple table with single row having two columns. I have added label in the first column and close button image in the next column. It is working fine when I added the image but not working when I add push button instead of image.
Please let me know if I am doing anything wrong. Public class DefaultHeader extends Widget implements ClickHandler{ private final Element labelTD; private final Element imageTD; private Image iconImage; interface DefaultImages extends ClientBundle { ImageResource closebtn(); } private static final DefaultImages DEFAULT_IMAGES = GWT.create(DefaultImages.class); public DefaultHeader(String text){ this(DEFAULT_IMAGES.closebtn(),text); } public DefaultHeader(ImageResource image, String text) { iconImage = new Image(image); // I do not need any Widgets here, just a DOM structure. Element root = DOM.createTable(); Element tbody = DOM.createTBody(); Element tr = DOM.createTR(); imageTD = DOM.createTD(); labelTD = DOM.createTD(); setElement(root); DOM.appendChild(root, tbody); DOM.appendChild(tbody, tr); DOM.appendChild(tr, labelTD); DOM.appendChild(tr, imageTD); // set image TD to be same width as image. DOM.setElementProperty(labelTD, "align", "left"); DOM.setElementProperty(imageTD, "align", "right"); DOM.setElementProperty(imageTD, "valign", "middle"); DOM.setStyleAttribute(imageTD, "width", iconImage.getWidth() + "px"); DOM.setStyleAttribute(labelTD, "width", "100%"); PushButton closeButton = new PushButton(iconImage); closeButton.addClickHandler(this); setButton(closeButton); //setImage(iconImage); setText(text); } public final String getText() { return DOM.getInnerText(labelTD); } public final void setText(String text) { DOM.setInnerText(labelTD, text); } public final void setButton(PushButton button) { DOM.appendChild(imageTD, button.getElement()); } public final void setImage(Image image) { iconImage = image; DOM.appendChild(imageTD, iconImage.getElement()); } public final Image getImage() { return iconImage; } @Override public void onClick(ClickEvent event) { this.setVisible(false); } } Satish -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.