Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package org.balisunrise.vaadin.components.header; import com.vaadin.event.LayoutEvents; import com.vaadin.server.FontAwesome; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Link; import com.vaadin.ui.Window; /** * * @author Glauco */ public class UserBar extends HorizontalLayout { private Link userName; private Configuration configuration; private LoginWindow login; public UserBar() { init(); } private void init() { setHeight("100%"); setWidthUndefined(); setStyleName("b-user-bar"); setSpacing(true); addLayoutClickListener(this::click); userName = new Link("Entrar", null); userName.setStyleName("b-user-name"); userName.setIcon(FontAwesome.USER); addComponent(userName); configuration = new Configuration(); addComponent(configuration); } public void click(LayoutEvents.LayoutClickEvent evt) { if (evt.getClickedComponent() == userName) { if (login == null) { login = new LoginWindow(); login.addCloseListener(this::closeLogin); getUI().addWindow(login); } } } public void closeLogin(Window.CloseEvent evt) { login = null; } }