com.squadd.UI.PlaceLayout.java Source code

Java tutorial

Introduction

Here is the source code for com.squadd.UI.PlaceLayout.java

Source

/*
 * 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 com.squadd.UI;

import com.vaadin.ui.Alignment;
import com.vaadin.ui.Component;
import com.vaadin.ui.FormLayout;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.TextField;

/**
 *
 * @author SharkNado
 */
public class PlaceLayout extends FormLayout {
    private TextField street;
    private TextField city;
    private boolean inUse = false;

    public PlaceLayout() {
        setVisible(false);
        configureComponents();
        buildLayout();
    }

    public TextField getStreet() {
        return street;
    }

    public TextField getCity() {
        return city;
    }

    private void configureComponents() {
        street = new TextField("Street");
        city = new TextField("City");
    }

    public void setStreet(TextField street) {
        this.street = street;
    }

    public void setCity(TextField city) {
        this.city = city;
    }

    private void buildLayout() {
        HorizontalLayout streetLayout = new HorizontalLayout(street);
        centerAligningComponent(streetLayout, street);

        HorizontalLayout cityLayout = new HorizontalLayout(city);
        centerAligningComponent(cityLayout, city);

        addComponents(cityLayout, streetLayout);
    }

    public boolean isInUse() {
        return inUse;
    }

    public void setInUse(boolean inUse) {
        this.inUse = inUse;
    }

    private void centerAligningComponent(HorizontalLayout where, Component what) {
        where.setSizeFull();
        where.setComponentAlignment(what, Alignment.TOP_CENTER);
    }

}