com.cerebro.provevaadin.Equipment.java Source code

Java tutorial

Introduction

Here is the source code for com.cerebro.provevaadin.Equipment.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.cerebro.provevaadin;

import com.vaadin.server.FileResource;
import com.vaadin.server.VaadinService;
import com.vaadin.ui.AbsoluteLayout;
import com.vaadin.ui.GridLayout;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Image;
import com.vaadin.ui.Panel;
import com.vaadin.ui.VerticalLayout;
import java.io.File;

/**
 *
 * @author matteo
 */
class Equipment extends HorizontalLayout {

    Panel sinistra = new Panel();
    Panel destra = new Panel();
    AbsoluteLayout root = new AbsoluteLayout();
    VerticalLayout rootDx = new VerticalLayout();
    String basepath = VaadinService.getCurrent().getBaseDirectory().getAbsolutePath() + "/WEB-INF/images/";

    public Equipment() {
        GridLayout contentSx = new GridLayout(15, 18);
        contentSx.setId("equip_body");
        contentSx.setHeight("600px");
        contentSx.setWidth("300px");

        FileResource helmetFile = new FileResource(new File(basepath + "red.png"));
        Image helmet = new Image("Helmet", helmetFile);
        helmet.setHeight("100px");
        contentSx.addComponent(helmet, 8, 0);

        sinistra.setContent(contentSx);
        //        root.setWidth("300px");
        //        root.setHeight("600px");
        //        
        //        FileResource bodyMaleFile = new FileResource(new File(basepath + "body-male.jpg"));
        //        FileResource helmetFile = new FileResource(new File(basepath + "red.png"));
        //        
        //        Image image = new Image("MaleBody", bodyMaleFile);
        //        image.setWidth(root.getWidth(), root.getWidthUnits());
        //        Image helmet = new Image("Helmet", helmetFile);
        //        helmet.setHeight("100px");
        //        
        //        root.addComponent(image, "left: 0px; top: 0px;");
        //        root.addComponent(helmet, "left: 50%; top: 100px");
        //        
        //        sinistra.setContent(root);
        //        
        //        
        //        destra.setContent(rootDx);
        //        
        this.addComponents(sinistra, destra);
    }

}