当前位置: 首页>>代码示例>>Java>>正文


Java Label类代码示例

本文整理汇总了Java中com.vaadin.v7.ui.Label的典型用法代码示例。如果您正苦于以下问题:Java Label类的具体用法?Java Label怎么用?Java Label使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Label类属于com.vaadin.v7.ui包,在下文中一共展示了Label类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addUserLabel

import com.vaadin.v7.ui.Label; //导入依赖的package包/类
private void addUserLabel(AttendeeHistory history) {
    String userInfo = "";
    if (history.getUser() != null) {
        User user = history.getUser();
        if (user.getFirstName() != null || user.getLastName() != null) {
            userInfo = String.format("%s %s (%s)", user.getFirstName(), user.getLastName(), user.getUsername());
        } else {
            userInfo = user.getUsername();
        }
    }

    Label userLabel = new Label(userInfo);
    userLabel.setStyleName(ValoTheme.LABEL_BOLD);
    userLabel.setStyleName(ValoTheme.LABEL_SMALL);
    userLabel.setSizeUndefined();

    addComponent(userLabel, 0, 0);
    setComponentAlignment(userLabel, Alignment.MIDDLE_LEFT);
}
 
开发者ID:kumoregdev,项目名称:kumoreg,代码行数:20,代码来源:HistoryEntryLayout.java

示例2: testAddComponentColumn

import com.vaadin.v7.ui.Label; //导入依赖的package包/类
@Test
public void testAddComponentColumn() {
    ComponentGrid grid = createTestGrid();

    Item firstItem = grid.getContainerDataSource().getItem(grid.getContainerDataSource().getIdByIndex(0));
    assertThat((String) firstItem.getItemProperty(COLUMN_CAPTION).getValue(), is(FOO_0));

    grid.addComponentColumn(COLUMN_CAPTION, new ComponentGenerator<ExampleBean>() {
        @Override
        public Component getComponent(ExampleBean bean) {
            return new Label(bean.getCaption());
        }
    });

    firstItem = grid.getContainerDataSource().getItem(grid.getContainerDataSource().getIdByIndex(0));
    assertThat(firstItem.getItemProperty(COLUMN_CAPTION).getValue(), is(instanceOf(Label.class)));

    Label firstLabel = (Label) firstItem.getItemProperty(COLUMN_CAPTION).getValue();
    assertThat(firstLabel.getValue(), is(FOO_0));
}
 
开发者ID:datenhahn,项目名称:componentrenderer,代码行数:21,代码来源:ComponentGridTest.java

示例3: testGenerateComponentHeaders

import com.vaadin.v7.ui.Label; //导入依赖的package包/类
@Test
public void testGenerateComponentHeaders() {
    ComponentGrid grid = createTestGrid();

    String headerText = grid.getDefaultHeaderRow().getCell(COLUMN_CAPTION).getText();

    assertThat(headerText, is("Caption"));
    grid.generateHeaders(new ComponentHeaderGenerator() {
        @Override
        public Label getHeader(Object propertyId) {
            return new Label("" + propertyId);
        }
    });

    Component headerComponent = grid.getDefaultHeaderRow().getCell(COLUMN_CAPTION).getComponent();
    assertThat(headerComponent, instanceOf(Label.class));
}
 
开发者ID:datenhahn,项目名称:componentrenderer,代码行数:18,代码来源:ComponentGridTest.java

示例4: createTestGrid

import com.vaadin.v7.ui.Label; //导入依赖的package包/类
private ComponentGrid createTestGrid() {
    ComponentGrid<ExampleBean> grid = new ComponentGrid(ExampleBean.class);
    grid.setDetailsGenerator(new Grid.DetailsGenerator() {
        @Override
        public Component getDetails(Grid.RowReference rowReference) {
            return new Label("foo");
        }
    });
    for(int i = 0; i < 10;i++) {
        ExampleBean bean = new ExampleBean();
        bean.setCaption("foo" +i);
        bean.setIsSomething(true);
        grid.add(bean);
    }
    return grid;
}
 
开发者ID:datenhahn,项目名称:componentrenderer,代码行数:17,代码来源:ComponentGridTest.java

示例5: testAddComponentColumn

import com.vaadin.v7.ui.Label; //导入依赖的package包/类
@Test
public void testAddComponentColumn() {
    Grid grid = createTestGrid();
    ComponentGridDecorator<ExampleBean> decorator = new ComponentGridDecorator<>(grid, ExampleBean.class);

    Item firstItem = grid.getContainerDataSource().getItem(grid.getContainerDataSource().getIdByIndex(0));
    assertThat((String) firstItem.getItemProperty(COLUMN_CAPTION).getValue(), is(FOO_0));

    decorator.addComponentColumn(COLUMN_CAPTION, new ComponentGenerator<ExampleBean>() {
        @Override
        public Component getComponent(ExampleBean bean) {
            return new Label(bean.getCaption());
        }
    });

    firstItem = grid.getContainerDataSource().getItem(grid.getContainerDataSource().getIdByIndex(0));
    assertThat(firstItem.getItemProperty(COLUMN_CAPTION).getValue(), is(instanceOf(Label.class)));

    Label firstLabel = (Label) firstItem.getItemProperty(COLUMN_CAPTION).getValue();
    assertThat(firstLabel.getValue(), is(FOO_0));
}
 
开发者ID:datenhahn,项目名称:componentrenderer,代码行数:22,代码来源:ComponentGridDecoratorTest.java

示例6: testGenerateComponentHeaders

import com.vaadin.v7.ui.Label; //导入依赖的package包/类
@Test
public void testGenerateComponentHeaders() {
    Grid grid = createTestGrid();
    ComponentGridDecorator<ExampleBean> decorator = new ComponentGridDecorator<>(grid, ExampleBean.class);

    String headerText = grid.getDefaultHeaderRow().getCell(COLUMN_CAPTION).getText();

    assertThat(headerText, is("Caption"));
    decorator.generateHeaders(new ComponentHeaderGenerator() {
        @Override
        public Label getHeader(Object propertyId) {
            return new Label("" + propertyId);
        }
    });

    Component headerComponent = grid.getDefaultHeaderRow().getCell(COLUMN_CAPTION).getComponent();
    assertThat(headerComponent, instanceOf(Label.class));
}
 
开发者ID:datenhahn,项目名称:componentrenderer,代码行数:19,代码来源:ComponentGridDecoratorTest.java

示例7: createTestGrid

import com.vaadin.v7.ui.Label; //导入依赖的package包/类
private Grid createTestGrid() {
    Grid grid = new Grid();
    BeanItemContainer<ExampleBean> bic = new BeanItemContainer<>(ExampleBean.class);
    grid.setContainerDataSource(bic);
    grid.setDetailsGenerator(new Grid.DetailsGenerator() {
        @Override
        public Component getDetails(Grid.RowReference rowReference) {
            return new Label("foo");
        }
    });
    for(int i = 0; i < 10;i++) {
        ExampleBean bean = new ExampleBean();
        bean.setCaption("foo" +i);
        bean.setIsSomething(true);
        bic.addBean(bean);
    }
    return grid;
}
 
开发者ID:datenhahn,项目名称:componentrenderer,代码行数:19,代码来源:ComponentGridDecoratorTest.java

示例8: getDetails

import com.vaadin.v7.ui.Label; //导入依赖的package包/类
@Override
public Component getDetails(Grid.RowReference rowReference) {
    rowReference.getGrid().scrollTo(rowReference.getItemId());
    Customer customer = (Customer)rowReference.getItemId();

    HorizontalLayout layout = new HorizontalLayout();
    layout.setHeight(300, Sizeable.Unit.PIXELS);
    layout.setMargin(true);
    layout.setSpacing(true);
    Image image = new Image("", customer.getPhoto());
    image.setHeight(200, Sizeable.Unit.PIXELS);
    image.setWidth(200, Sizeable.Unit.PIXELS);
    layout.addComponent(image);
    Label nameLabel = new Label("<h1>" + customer.getFirstName() + " " + customer.getLastName() + "</h1>", ContentMode.HTML);
    layout.addComponent(nameLabel);
    layout.setExpandRatio(nameLabel, 1.0f);
    return layout;
}
 
开发者ID:datenhahn,项目名称:componentrenderer,代码行数:19,代码来源:CustomerDetailsGenerator.java

示例9: getDetails

import com.vaadin.v7.ui.Label; //导入依赖的package包/类
@Override
public Component getDetails(Grid.RowReference rowReference) {
    rowReference.getGrid().scrollTo(rowReference.getItemId());
    StaticCustomer customer = (StaticCustomer)rowReference.getItemId();

    HorizontalLayout layout = new HorizontalLayout();
    layout.setHeight(300, Sizeable.Unit.PIXELS);
    layout.setMargin(true);
    layout.setSpacing(true);
    Image image = new Image("", customer.getPhoto());
    image.setHeight(200, Sizeable.Unit.PIXELS);
    image.setWidth(200, Sizeable.Unit.PIXELS);
    layout.addComponent(image);
    Label nameLabel = new Label("<h1>" + customer.getFirstName() + " " + customer.getLastName() + "</h1>", ContentMode.HTML);
    layout.addComponent(nameLabel);
    layout.setExpandRatio(nameLabel, 1.0f);
    return layout;
}
 
开发者ID:datenhahn,项目名称:componentrenderer,代码行数:19,代码来源:StaticCustomerDetailsGenerator.java

示例10: createRating

import com.vaadin.v7.ui.Label; //导入依赖的package包/类
public static CssLayout createRating(Customer customer) {
    CssLayout layout = new CssLayout();
    layout.setHeight(49, Sizeable.Unit.PIXELS);
    layout.setWidth(100, Sizeable.Unit.PIXELS);

    Label overallRating = new Label(FontAwesome.STAR.getHtml(), ContentMode.HTML);
    overallRating.addStyleName("green");
    overallRating.setDescription("Very good : " + testData.getNumberBetween(90, 100) + "% Chance");
    overallRating.setWidthUndefined();
    overallRating.setWidth(49, Sizeable.Unit.PIXELS);
    overallRating.setHeight(49, Sizeable.Unit.PIXELS);
    layout.addComponent(overallRating);


    Label carRating = new Label(FontAwesome.CAR.getHtml(), ContentMode.HTML);
    carRating.addStyleName("red");
    carRating.setDescription("Unlikely : " + testData.getNumberBetween(1, 15) + "%");
    carRating.setWidthUndefined();
    carRating.setWidth(49, Sizeable.Unit.PIXELS);
    carRating.setHeight(49, Sizeable.Unit.PIXELS);

    layout.addComponent(carRating);

    return layout;
}
 
开发者ID:datenhahn,项目名称:componentrenderer,代码行数:26,代码来源:ViewComponents.java

示例11: createFoodIcon

import com.vaadin.v7.ui.Label; //导入依赖的package包/类
public static Component createFoodIcon(Customer cust) {
    Label label = new Label(FontAwesome.HOURGLASS_2.getHtml(), ContentMode.HTML);

    label.setHeight(24, Sizeable.Unit.PIXELS);
    label.setWidth(30, Sizeable.Unit.PIXELS);

    if (cust.getFood() == Customer.Food.HAMBURGER) {
        label.setValue(FontAwesome.AMBULANCE.getHtml());
    }

    if (cust.getFood() == Customer.Food.FISH) {
        label.setValue(FontAwesome.HEART.getHtml());
    }

    if (cust.getFood() == Customer.Food.VEGETABLES) {
        label.setValue(FontAwesome.SUN_O.getHtml());
    }

    return label;

}
 
开发者ID:datenhahn,项目名称:componentrenderer,代码行数:22,代码来源:ViewComponents.java

示例12: getTestComponent

import com.vaadin.v7.ui.Label; //导入依赖的package包/类
@Override
public Component getTestComponent() {
    Label info = new Label();
    info.setValue("Hide and/or sort columns."
            + " Grid will save your settings in the browser cookies."
            + " And load them next time you open the view");

    MGrid<Person> table = new MGrid<>();
    table.setRows(
            new Person(1, "Some", "One", 13),
            new Person(2, "Arni", "Red", 83),
            new Person(3, "Sami", "Green", 42),
            new Person(4, "Togy", "Tilly", 23),
            new Person(5, "Billy", "Willy", 22),
            new Person(6, "Anna", "Bunny", 23),
            new Person(7, "Joe", "Black", 52)
    );
    makeGridColumnsHideable(table);
    makeGridOrderable(table);
    table.setColumnReorderingAllowed(true);
    table.attachSaveSettings("personsGrid");

    return new MVerticalLayout(info, table);
}
 
开发者ID:viritin,项目名称:viritin,代码行数:25,代码来源:GridSaveSettingsTest.java

示例13: createView

import com.vaadin.v7.ui.Label; //导入依赖的package包/类
NavigationView createView(String caption, String debugId,
        boolean hasNext) {
    final CssLayout layout = new CssLayout();
    layout.setId(debugId);
    int max = (int) (r.nextInt(100));
    for (int i = 0; i < max; i++) {
        Label l = new Label("Foo " + i);
        layout.addComponent(l);
    }

    NavigationView navView = new NavigationView();
    if (hasNext) {
        navView.setRightComponent(new Button("Next"));
    }
    navView.setCaption(caption);
    navView.setContent(layout);
    navView.getLeftComponent().setCaption("Back");
    return navView;
}
 
开发者ID:vaadin,项目名称:touchkit,代码行数:20,代码来源:TableAndNavigationManager.java

示例14: TableThing

import com.vaadin.v7.ui.Label; //导入依赖的package包/类
public TableThing() {
    setCaption(getClass().getSimpleName());

    CssLayout layout = new CssLayout();
    setContent(layout);

    layout.addComponent(new Label("A fairly long table follows"));

    Table tbl = new Table();
    tbl.setSelectable(true);
    tbl.addContainerProperty("Name", String.class, "John Doe");
    tbl.addContainerProperty("Area", String.class, "A12");
    tbl.addContainerProperty("Date", String.class, "5/23/13");
    tbl.addContainerProperty("Start", String.class, "7:00 AM");
    tbl.addContainerProperty("End", String.class, "3:00 PM");
    for (int i = 0; i < 50; i++) {
        tbl.addItem();
    }
    layout.addComponent(tbl);
}
 
开发者ID:vaadin,项目名称:touchkit,代码行数:21,代码来源:ThemeTest.java

示例15: MoveStuff

import com.vaadin.v7.ui.Label; //导入依赖的package包/类
public MoveStuff() {
    setDescription("Move stuff from view to another");
    
    HorizontalLayout horizontalLayout = new HorizontalLayout();
    horizontalLayout.setSizeFull();
    
    navigationView = new NavigationView("First");
    navigationView.setWidth("40%");
    navigationView.setId("first ");
    
    
    c = new Label("Foo");
    c.setId("stuff");
    navigationView.setContent(c);
    
    Button button = new Button("Move", this);
    navigationView.setRightComponent(button);
    

    another = new NavigationView("Another");
    another.setId("another ");
    another.setWidth("40%");
    
    horizontalLayout.addComponents(navigationView, another);
    addComponent(horizontalLayout);
}
 
开发者ID:vaadin,项目名称:touchkit,代码行数:27,代码来源:MoveStuff.java


注:本文中的com.vaadin.v7.ui.Label类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。