Time for action – creating an extension
The steps for creating an extension to hide a label when the mouse pointer moves over it are as follows:
Create a new Vaadin project with the name extension using your IDE.
Create a new server-side extension class:
public class HideOnHover extends AbstractExtension { public void extend(Label label) { super.extend(label); } }
Create a new client side connector (remember to put this class inside a
.client
package):@Connect(HideOnHover.class) public class HideOnHoverConnector extends AbstractExtensionConnector { @Override protected void extend(ServerConnector target) { final Widget widget = ((ComponentConnector) target).getWidget(); widget.addHandler(new MouseOverHandler() { @Override public void onMouseOver(MouseOverEvent event) { widget.setVisible(false); } }, MouseOverEvent.getType()); } }
Use the extension in your UI class:
Label textField = new Label( "Do you dare to put the cursor over...