Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can try this out, slightly improved solution by fungus1487:</p> <pre><code>import com.google.gwt.dom.client.EventTarget; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.i18n.client.HasDirection; import com.google.gwt.user.client.Element; import com.google.gwt.user.client.ui.*; /** * @author Andrey Talnikov */ public class ClosablePopup extends DialogBox { private Anchor closeAnchor; /** * Instantiates new closable popup. * * @param title the title * @param defaultClose it {@code true}, hide popup on 'x' click */ public ClosablePopup(String title, boolean defaultClose) { super(true); closeAnchor = new Anchor("x"); FlexTable captionLayoutTable = new FlexTable(); captionLayoutTable.setWidth("100%"); captionLayoutTable.setText(0, 0, title); captionLayoutTable.setWidget(0, 1, closeAnchor); captionLayoutTable.getCellFormatter().setHorizontalAlignment(0, 1, HasHorizontalAlignment.HorizontalAlignmentConstant.endOf(HasDirection.Direction.LTR)); HTML caption = (HTML) getCaption(); caption.getElement().appendChild(captionLayoutTable.getElement()); caption.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { EventTarget target = event.getNativeEvent().getEventTarget(); Element targetElement = (Element) target.cast(); if (targetElement == closeAnchor.getElement()) { closeAnchor.fireEvent(event); } } }); if (defaultClose) { addCloseHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { hide(); } }); } } public void addCloseHandler(ClickHandler handler) { closeAnchor.addClickHandler(handler); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload