com.squadd.UI.MessageLayout.java Source code

Java tutorial

Introduction

Here is the source code for com.squadd.UI.MessageLayout.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.squadd.technical.Display;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Image;
import com.vaadin.ui.Label;
import com.vaadin.ui.Panel;
import com.vaadin.ui.VerticalLayout;

/**
 *
 * @author SharkNado
 */
public class MessageLayout extends HorizontalLayout {
    private Label when;
    private Image groupPhoto;
    private Label text;

    public MessageLayout(Label when, Image groupPhoto, Label text) {
        this.when = when;
        this.groupPhoto = groupPhoto;
        this.text = text;
        configureLayout();
    }

    private void configureLayout() {
        VerticalLayout all = new VerticalLayout();
        HorizontalLayout dates = new HorizontalLayout(when);
        dates.setSpacing(true);
        when.setSizeUndefined();
        Panel panel = new Panel();
        panel.setWidth(Display.width * 0.3 + "px");
        panel.setContent(text);
        groupPhoto.setWidth(Display.width * 0.05 + "px");
        groupPhoto.setHeight(Display.height * 0.05 + "px");
        HorizontalLayout other = new HorizontalLayout(groupPhoto, panel);
        all.addComponents(dates, other);
        Panel wrap = new Panel();
        wrap.setContent(all);
        addComponent(wrap);
    }

    public void setWhen(Label when) {
        this.when = when;
    }

    public void setGroupPhoto(Image groupPhoto) {
        this.groupPhoto = groupPhoto;
    }

    public void setText(Label text) {
        this.text = text;
    }

    public Label getWhen() {
        return when;
    }

    public Image getGroupPhoto() {
        return groupPhoto;
    }

    public Label getText() {
        return text;
    }

}