Java tutorial
/** * Copyright 2013 Universidad Icesi * * This file is part of SongStock. * * SongStock is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * SongStock is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with SongStock. If not, see <http://www.gnu.org/licenses/>. **/ package songstock.web.extensions.payments; import com.vaadin.annotations.AutoGenerated; import com.vaadin.ui.AbsoluteLayout; import com.vaadin.ui.Button; import com.vaadin.ui.CustomComponent; import com.vaadin.ui.Label; /** * * @author Andrs Paz * */ public class PaymentMethodsPanel extends CustomComponent { /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */ @AutoGenerated private AbsoluteLayout mainLayout; @AutoGenerated private Label labelTitle; private static final long serialVersionUID = 1L; private int xPosition; /** * The constructor should first build the main layout, set the composition * root and then do any custom initialization. * * The constructor will not be automatically regenerated by the visual * editor. */ public PaymentMethodsPanel() { buildMainLayout(); setCompositionRoot(mainLayout); // User code xPosition = 100; } public void addPaymentMethod(Button paymentMethodButton) { try { mainLayout.removeComponent(paymentMethodButton); } catch (Exception e) { } mainLayout.addComponent(paymentMethodButton, "top:0px;left:" + xPosition + "px;"); xPosition += 100; } @AutoGenerated private AbsoluteLayout buildMainLayout() { // common part: create layout mainLayout = new AbsoluteLayout(); mainLayout.setImmediate(false); mainLayout.setWidth("100%"); mainLayout.setHeight("60px"); // top-level component properties setWidth("100.0%"); setHeight("60px"); // labelTitle labelTitle = new Label(); labelTitle.setImmediate(false); labelTitle.setWidth("-1px"); labelTitle.setHeight("-1px"); labelTitle.setValue("<b>Payment With:</b>"); labelTitle.setContentMode(com.vaadin.shared.ui.label.ContentMode.HTML); mainLayout.addComponent(labelTitle, "top:5px;left:0px;"); return mainLayout; } }