我如何在vaadin中迭代手风琴?

时间:2015-05-18 13:45:04

标签: java iterator accordion vaadin

我想做这样的事情:

background-position: 0px -1683px;

但" c"变量总是为空,所以问题是,如何获得手风琴中标签的标题?

感谢。

编辑:MChaker,就在这里!

background-position: 0px -2057px;

Iterator<Component> componentIterator = accordion.iterator(); while (componentIterator.hasNext()) { Accordion c = (Accordion) componentIterator.next(); System.out.println("test: " + c.getCaption()); } 方法:

    @PostConstruct
public void posInit() {
    VerticalLayout layoutGeral = LayoutFactory.vertical();

    TabSheet tabSheet = new TabSheet();
    tabSheet.setCaption("Editar");
    tabSheet.setWidth(ConstantesUI.CEM_POR_CENTO);
    tabSheet.setHeight(400, Unit.PIXELS);

    Accordion accordion = new Accordion();

    addTabsToAccordion(accordion);

    accordion.setWidth(1170, Unit.PIXELS);
    accordion.setHeight(600, Unit.PIXELS);

    if (accordion != null && accordion.getCaption() != null) {
        if (accordion.getCaption().equals("Configurações Gerais")) {
            accordion.setWidth(1200, Unit.PIXELS);
            accordion.setHeight(240, Unit.PIXELS);
        }
    }

    tabSheet.addComponent(accordion);

    final Panel panel = new Panel();
    panel.setHeight(550, Unit.PIXELS);
    panel.setScrollLeft(0);

    panel.setContent(tabSheet);

    layoutGeral.addComponent(LayoutFactory.titulo("Propriedades"));
    layoutGeral.addComponent(LayoutFactory.conteudo(panel, new HorizontalSplitPanel(), addSaveButton()));

    addComponent(layoutGeral);

    setSizeFull();
}

addTabsToAccordion方法:

accordion.addTab(buildTabEmail(this.props), "Email");

1 个答案:

答案 0 :(得分:0)

这是什么意思?

TabSheet tabsheet= new TabSheet();
// Create an example of tab
VerticalLayout tabExample= new VerticalLayout();
tabExample.addComponent(new Embedded(null,
       new ThemeResource("anyImage.jpg")));
tabExample.setCaption("Example");
tabsheet.addTab(tabExample).setIcon(
        new ThemeResource("anyIcon.png"));


Iterator<Component> componentIterator = tabsheet.getComponentIterator();
while (componentIterator.hasNext()) {
    Component c = (Component) componentIterator.next();
    Tab tab = tabsheet.getTab(c);
    System.out.println("test: " + tab.getCaption());
}