List of usage examples for com.vaadin.ui HorizontalLayout setComponentAlignment
@Override public void setComponentAlignment(Component childComponent, Alignment alignment)
From source file:com.mycollab.vaadin.web.ui.StyleCalendarExp.java
License:Open Source License
public StyleCalendarExp() { this.setWidth("230px"); this.setHeightUndefined(); this.setSpacing(false); this.setStyleName("stylecalendar-ext"); this.setMargin(new MarginInfo(true, false, false, false)); styleCalendar.setRenderHeader(false); styleCalendar.setRenderWeekNumbers(false); styleCalendar.setImmediate(true);/* w w w . j av a 2 s. c o m*/ styleCalendar.setWidth("100%"); setDateOptionsGenerator(); btnShowNextYear = new Button(); btnShowNextYear.setIcon( new ExternalResource(StorageFactory.generateAssetRelativeLink("icons/16/cal_year_next.png"))); btnShowNextYear.setStyleName(WebThemes.BUTTON_LINK); btnShowNextMonth = new Button(); btnShowNextMonth.setIcon( new ExternalResource(StorageFactory.generateAssetRelativeLink("icons/16/cal_month_next.png"))); btnShowNextMonth.setStyleName(WebThemes.BUTTON_LINK); btnShowPreviousMonth = new Button(); btnShowPreviousMonth.setIcon( new ExternalResource(StorageFactory.generateAssetRelativeLink("icons/16/cal_month_pre.png"))); btnShowPreviousMonth.setStyleName(WebThemes.BUTTON_LINK); btnShowPreviousYear = new Button(); btnShowPreviousYear.setIcon( new ExternalResource(StorageFactory.generateAssetRelativeLink("icons/16/cal_year_pre.png"))); btnShowPreviousYear.setStyleName(WebThemes.BUTTON_LINK); lbSelectedDate.setValue(UserUIContext.formatDate(new Date())); lbSelectedDate.addStyleName("calendarDateLabel"); lbSelectedDate.setWidth("80"); HorizontalLayout layoutControl = new HorizontalLayout(); layoutControl.setStyleName("calendarHeader"); layoutControl.setWidth("100%"); layoutControl.setHeight("35px"); HorizontalLayout layoutButtonPrevious = new HorizontalLayout(); layoutButtonPrevious.setSpacing(true); layoutButtonPrevious.addComponent(btnShowPreviousYear); layoutButtonPrevious.setComponentAlignment(btnShowPreviousYear, Alignment.MIDDLE_LEFT); layoutButtonPrevious.addComponent(btnShowPreviousMonth); layoutButtonPrevious.setComponentAlignment(btnShowPreviousMonth, Alignment.MIDDLE_LEFT); layoutControl.addComponent(layoutButtonPrevious); layoutControl.setComponentAlignment(layoutButtonPrevious, Alignment.MIDDLE_LEFT); layoutControl.addComponent(lbSelectedDate); layoutControl.setComponentAlignment(lbSelectedDate, Alignment.MIDDLE_CENTER); MHorizontalLayout layoutButtonNext = new MHorizontalLayout(); layoutButtonNext.addComponent(btnShowNextMonth); layoutButtonNext.setComponentAlignment(btnShowNextMonth, Alignment.MIDDLE_RIGHT); layoutButtonNext.addComponent(btnShowNextYear); layoutButtonNext.setComponentAlignment(btnShowNextYear, Alignment.MIDDLE_RIGHT); layoutControl.addComponent(layoutButtonNext); layoutControl.setComponentAlignment(layoutButtonNext, Alignment.MIDDLE_RIGHT); this.addComponent(layoutControl); this.setComponentAlignment(layoutControl, Alignment.TOP_CENTER); this.addComponent(styleCalendar); this.setExpandRatio(styleCalendar, 1.0f); }
From source file:com.naoset.framework.frontend.view.window.Window.java
private HorizontalLayout buildFooter() { HorizontalLayout layout = new HorizontalLayout(); layout.addStyleName(ValoTheme.WINDOW_BOTTOM_TOOLBAR); layout.setWidth(100.0f, Unit.PERCENTAGE); //Si el objeto a mostrar hereda de Widget, mostraremos su cabecera con el men en la ventana. if (Widget.class.isInstance(body)) { //if (details.getClass().isInstance(Widget.class)) { Widget aux = (Widget) body;//from w w w . j a va 2 s . co m HorizontalLayout header = aux.getHeader(); header.setWidth(100.0f, Unit.PERCENTAGE); layout.addComponent(header); //layout.setComponentAlignment(header, Alignment.TOP_LEFT); layout.setExpandRatio(header, 1); } Button ok = new Button("Cerrar"); ok.addStyleName(ValoTheme.BUTTON_PRIMARY); ok.addClickListener(new Button.ClickListener() { @Override public void buttonClick(final Button.ClickEvent event) { Boolean canClose = true; if (Widget.class.isInstance(body)) { Widget aux = (Widget) body; canClose = !aux.isModified(); } if (canClose) { close(); } else { buildConfirmCloseDialog(); } } }); ok.focus(); layout.addComponent(ok); layout.setComponentAlignment(ok, Alignment.TOP_RIGHT); return layout; }
From source file:com.neatresults.mgnltweaks.neatu2b.ui.form.field.U2BField.java
License:Open Source License
/** * Initialize the field. <br>//from ww w . ja v a 2 s. co m * Create as many configured Field as we have related values already stored. */ @Override protected void initFields(final PropertysetItem newValue) { root.removeAllComponents(); final TextField id = createTextField("Id", newValue); root.addComponent(id); final TextField title = createTextField("Title", newValue); root.addComponent(title); final TextFieldDefinition def = new TextFieldBuilder("description").label("Description").rows(3) .definition(); final TextArea description = (TextArea) createLocalField(def, newValue.getItemProperty(def.getName()), false); newValue.addItemProperty(def.getName(), description.getPropertyDataSource()); description.setNullRepresentation(""); description.setWidth("100%"); description.setNullSettingAllowed(true); root.addComponent(description); HorizontalLayout ddLine = new HorizontalLayout(); final TextField publishedAt = createTextField("Published", newValue); ddLine.addComponent(publishedAt); final TextField duration = createTextField("Duration", newValue); ddLine.addComponent(duration); ddLine.addComponent(createTextField("Definition", newValue)); Button fetchButton = new Button("Fetch metadata"); fetchButton.addStyleName("magnoliabutton"); fetchButton.addClickListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { String idStr = id.getValue(); // extract id from url when whole url is passed if (idStr.startsWith("http")) { idStr = StringUtils.substringBefore(StringUtils.substringAfter(idStr, "?v="), "&"); } U2BService service = null; try { RestEasyClient client = (RestEasyClient) restClientRegistry.getRestClient("youtube"); service = client.getClientService(U2BService.class); } catch (RegistrationException e) { log.error("Failed to get a client for [" + U2BService.class.getName() + "] with: " + e.getMessage(), e); } if (service != null) { String key = u2bModule.getGoogleKey(); JsonNode response = service.meta(idStr, "snippet", key); try { if (response.get("items").getElements().hasNext()) { JsonNode videoItem = response.get("items").getElements().next(); String descriptionStr = videoItem.get("snippet").get("description").getTextValue(); newValue.getItemProperty("description").setValue(descriptionStr); String titleStr = videoItem.get("snippet").get("title").getTextValue(); newValue.getItemProperty("title").setValue(titleStr); Iterator<Entry<String, JsonNode>> thumbs = videoItem.get("snippet").get("thumbnails") .getFields(); while (thumbs.hasNext()) { Entry<String, JsonNode> entry = thumbs.next(); newValue.getItemProperty(entry.getKey() + "Url") .setValue(entry.getValue().get("url").getTextValue()); newValue.getItemProperty(entry.getKey() + "Width") .setValue("" + entry.getValue().get("width").getLongValue()); newValue.getItemProperty(entry.getKey() + "Height") .setValue("" + entry.getValue().get("height").getLongValue()); } String publishedAtStr = videoItem.get("snippet").get("publishedAt").getTextValue(); newValue.getItemProperty("published").setValue(publishedAtStr); } } catch (Exception e) { log.error("Failed to parse the video metadata.", e); } response = service.meta(idStr, "contentDetails", key); try { if (response.get("items").getElements().hasNext()) { JsonNode videoItem = response.get("items").getElements().next(); String durationStr = videoItem.get("contentDetails").get("duration").getTextValue(); newValue.getItemProperty("duration").setValue(durationStr); String definition = videoItem.get("contentDetails").get("definition").getTextValue(); newValue.getItemProperty("definition").setValue(definition); } } catch (Exception e) { log.error("Failed to parse the video duration.", e); } } } }); ddLine.addComponent(fetchButton); ddLine.setWidth(100, Unit.PERCENTAGE); ddLine.setHeight(-1, Unit.PIXELS); ddLine.setComponentAlignment(fetchButton, Alignment.BOTTOM_RIGHT); root.addComponent(ddLine); PropertysetItem item = (PropertysetItem) getPropertyDataSource().getValue(); root.addComponent(createEntryComponent("default", item), root.getComponentCount() - 1); root.addComponent(createEntryComponent("standard", item), root.getComponentCount() - 1); root.addComponent(createEntryComponent("medium", item), root.getComponentCount() - 1); root.addComponent(createEntryComponent("high", item), root.getComponentCount() - 1); root.addComponent(createEntryComponent("maxres", item), root.getComponentCount() - 1); }
From source file:com.oodrive.nuage.webui.component.VvrOperationComponent.java
License:Apache License
@Override public final AbstractComponent createComponent(final VvrModel model, final ModelCreator handler) { final HorizontalLayout operationLayout = new HorizontalLayout(); operationLayout.setMargin(true);/*from w w w .j av a 2s . c o m*/ operationLayout.setSpacing(true); operationLayout.setWidth("100%"); // Start and description buttons // START/STOP final Button startStop = new Button(); startStop.setWidth(BUTTON_WIDTH); startStop.addStyleName(Runo.BUTTON_BIG); final Resource iconStartStop; final String description; if (!model.isVvrStarted()) { iconStartStop = WebUiResources.getStartIcon(); description = "Start"; } else { iconStartStop = WebUiResources.getStopIcon(); description = "Stop"; } startStop.setIcon(iconStartStop); startStop.setDescription(description); operationLayout.addComponent(startStop); operationLayout.setExpandRatio(startStop, 1f); operationLayout.setComponentAlignment(startStop, Alignment.MIDDLE_LEFT); final UUID vvrUuid = model.getItemUuid(); startStop.addClickListener(new Button.ClickListener() { @Override public void buttonClick(final ClickEvent event) { final boolean started = model.isVvrStarted(); // Start/Stop are done in background if (!started) { WaitingComponent.executeBackground(model, new Background() { @Override public void processing() { model.startVvr(); } @Override public void postProcessing() { startStop.setIcon(WebUiResources.getStopIcon()); startStop.setDescription("Stop"); Notification.show("VVR started ", vvrUuid.toString(), Notification.Type.TRAY_NOTIFICATION); } }); } else { WaitingComponent.executeBackground(model, new Background() { @Override public void processing() { model.stopVvr(); } @Override public void postProcessing() { startStop.setIcon(WebUiResources.getStartIcon()); startStop.setDescription("Start"); Notification.show("VVR stopped ", vvrUuid.toString(), Notification.Type.TRAY_NOTIFICATION); } }); } } }); // ATTRIBUTES final Button attributes = new Button(); attributes.addStyleName(Runo.BUTTON_BIG); attributes.setWidth(BUTTON_WIDTH); operationLayout.addComponent(attributes); operationLayout.setExpandRatio(attributes, 1f); operationLayout.setComponentAlignment(attributes, Alignment.MIDDLE_LEFT); attributes.setIcon(WebUiResources.getSettingsIcon()); attributes.setDescription("Settings"); attributes.addClickListener(new Button.ClickListener() { @Override public void buttonClick(final ClickEvent event) { try { final VvrAttributesWindow attributesWindow = new VvrAttributesWindow(vvrUuid); attributesWindow.add(model); } catch (final Exception e) { LOGGER.error("Can not get VVR attributes: ", e); final ErrorWindow err = new ErrorWindow("Can not display VVR Attributes: " + e.getMessage()); err.add(model); } } }); // DELETE final Button delete = new Button(); delete.addStyleName(Runo.BUTTON_BIG); delete.setWidth(BUTTON_WIDTH); delete.setIcon(WebUiResources.getTrashIcon()); delete.setDescription("Delete"); operationLayout.addComponent(delete); operationLayout.setExpandRatio(delete, 12f); operationLayout.setComponentAlignment(delete, Alignment.MIDDLE_RIGHT); delete.addClickListener(new Button.ClickListener() { @Override public void buttonClick(final ClickEvent event) { try { final VvrDeleteWindow deleteWindow = new VvrDeleteWindow(vvrUuid); deleteWindow.add(vvrManagerModel); } catch (final Exception e) { LOGGER.error("Can not delete VVR: ", e); final ErrorWindow err = new ErrorWindow("Can not delete VVR: " + e.getMessage()); err.add(model); } } }); return operationLayout; }
From source file:com.oodrive.nuage.webui.component.window.AbstractConfirmationWindow.java
License:Apache License
@SuppressWarnings("serial") @Override//from w w w . jav a 2 s .com public Window init(final AbstractItemModel model) { // Add new window final Window vvrConfirmationWindow = new Window("Confirmation"); vvrConfirmationWindow.center(); vvrConfirmationWindow.setResizable(false); final VerticalLayout vvrConfirmationLayout = new VerticalLayout(); vvrConfirmationLayout.setMargin(true); vvrConfirmationWindow.setContent(vvrConfirmationLayout); // Message to display before buttons final Label confirmationMessage = new Label(confirmation); vvrConfirmationLayout.addComponent(confirmationMessage); vvrConfirmationLayout.setComponentAlignment(confirmationMessage, Alignment.MIDDLE_CENTER); vvrConfirmationLayout.setSpacing(true); final HorizontalLayout buttonLayout = new HorizontalLayout(); vvrConfirmationLayout.addComponent(buttonLayout); // Button OK final Button okButton = new Button("OK"); buttonLayout.setSizeFull(); buttonLayout.addComponent(okButton); buttonLayout.setComponentAlignment(okButton, Alignment.MIDDLE_CENTER); okButton.addClickListener(new Button.ClickListener() { @Override public void buttonClick(final ClickEvent event) { try { action.execute(model); vvrConfirmationWindow.close(); } catch (final Exception e) { vvrConfirmationWindow.close(); } } }); // Button cancel final Button cancelButton = new Button("Cancel"); buttonLayout.addComponent(cancelButton); buttonLayout.setComponentAlignment(cancelButton, Alignment.MIDDLE_CENTER); cancelButton.addClickListener(new Button.ClickListener() { @Override public void buttonClick(final ClickEvent event) { // Just close the window vvrConfirmationWindow.close(); } }); return vvrConfirmationWindow; }
From source file:com.oodrive.nuage.webui.component.window.VvrAttributesWindow.java
License:Apache License
@SuppressWarnings("serial") @Override//w w w . j av a2 s.c o m public final Window init(final AbstractItemModel model) { // Cast model in vvrModel final VvrModel vvrModel = (VvrModel) model; // Add new window final Window vvrAttributesWindow = new Window("VVR Attributes"); vvrAttributesWindow.center(); vvrAttributesWindow.setWidth("400px"); vvrAttributesWindow.setResizable(false); final VerticalLayout layout = new VerticalLayout(); vvrAttributesWindow.setContent(layout); layout.setMargin(true); final FormLayout vvrAttributesLayout = new FormLayout(); layout.addComponent(vvrAttributesLayout); vvrAttributesLayout.setMargin(true); // Enter NAME String value = vvrModel.getVvrName(); if (value == null) { value = ""; } final TextField name = new TextField("Name", value); name.setSizeFull(); vvrAttributesLayout.addComponent(name); // Enter description value = vvrModel.getVvrDescription(); if (value == null) { value = ""; } final TextField desc = new TextField("Description", value); desc.setSizeFull(); vvrAttributesLayout.addComponent(desc); // Enter name final TextField vvrUUID = new TextField("UUID"); vvrUUID.setValue(vvrUuid.toString()); vvrUUID.setReadOnly(true); vvrUUID.setSizeFull(); vvrAttributesLayout.addComponent(vvrUUID); // OK button final HorizontalLayout hzlayout = new HorizontalLayout(); layout.addComponent(hzlayout); hzlayout.setSizeFull(); final Button okButton = new Button("OK"); hzlayout.addComponent(okButton); hzlayout.setComponentAlignment(okButton, Alignment.MIDDLE_CENTER); okButton.addClickListener(new Button.ClickListener() { @Override public void buttonClick(final ClickEvent event) { WaitingComponent.executeBackground(vvrModel, new Background() { @Override public void processing() { vvrModel.setVvrName(name.getValue()); vvrModel.setVvrDescription(desc.getValue()); } @Override public void postProcessing() { } }); vvrAttributesWindow.close(); } }); // Cancel button final Button cancelButton = new Button("Cancel"); hzlayout.addComponent(cancelButton); hzlayout.setComponentAlignment(cancelButton, Alignment.MIDDLE_CENTER); cancelButton.addClickListener(new Button.ClickListener() { @Override public void buttonClick(final ClickEvent event) { // Just close the window vvrAttributesWindow.close(); } }); return vvrAttributesWindow; }
From source file:com.oodrive.nuage.webui.VvrManagerUi.java
License:Apache License
@Override protected void init(final VaadinRequest request) { // Listener to disconnect JMX connection on exit. addDetachListener(new DetachListener() { @Override//from www . j a v a2 s. c o m public void detach(final DetachEvent event) { jmxHandler.disconnect(); } }); setPollInterval(1000); final Label labelLeft = new Label(""); final Label labelRight = new Label(""); labelLeft.setHeight("100%"); labelRight.setHeight("100%"); final HorizontalLayout content = new HorizontalLayout(); content.setSizeFull(); rootLayout.setWidth(rootLayoutWidth); rootLayout.setImmediate(true); rootLayout.addComponent(vvrManagerLayout); vvrManagerLayout.setMargin(false); vvrManagerLayout.setSpacing(true); vvrManagerLayout.setWidth(rootLayoutWidth); content.addComponent(labelLeft); content.addComponent(rootLayout); content.addComponent(labelRight); content.setExpandRatio(labelLeft, 0.5f); content.setExpandRatio(labelRight, 0.5f); content.setComponentAlignment(rootLayout, Alignment.TOP_CENTER); setContent(content); // Init Jmx Handler try { jmxHandler.connect(); // Init ui initVvrManagerUi(jmxHandler); } catch (final Exception e) { LOGGER.error("Can not connect to JMX", e); } }
From source file:com.openhris.employee.EmployeeSummaryUI.java
public EmployeeSummaryUI(int branchId) { this.branchId = branchId; setSizeFull();//from ww w.j a v a2 s. c om setSpacing(true); setMargin(new MarginInfo(true, true, false, false)); HorizontalLayout h = new HorizontalLayout(); h.setWidth("100%"); h.setMargin(true); h.setSpacing(true); final ComboBox employeeStatus = new ComboBox("Status: "); employeeStatus.setWidth("150px"); employeeStatus.setNullSelectionAllowed(false); employeeStatus.addItem("employed"); employeeStatus.addItem("resigned"); h.addComponent(employeeStatus); Button generateBtn = new Button("GENERATE EMPLOYEE SUMMARY"); generateBtn.setWidth("250px"); generateBtn.addListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { if (employeeStatus.getValue() == null) { getWindow().showNotification("Employee Status!", Window.Notification.TYPE_WARNING_MESSAGE); return; } tradeId = cs.getTradeIdByBranchId(getBranchId()); corporateId = cs.getCorporateIdByTradeId(tradeId); summary.setContainerDataSource( new EmployeeSummaryDataContainer(corporateId, employeeStatus.getValue().toString())); } }); h.addComponent(generateBtn); h.setComponentAlignment(generateBtn, Alignment.BOTTOM_LEFT); Button exportTableToExcel = new Button("EXPORT TO EXCEL"); exportTableToExcel.setWidth("250px"); exportTableToExcel.addListener(new Button.ClickListener() { private static final long serialVersionUID = -73954695086117200L; private ExcelExport excelExport; @Override public void buttonClick(Button.ClickEvent event) { excelExport = new ExcelExport(summary, "EMPLOYEE SUMMARY"); excelExport.excludeCollapsedColumns(); excelExport.setReportTitle(cs.getCorporateById(corporateId).toUpperCase() + " Employee Summary"); excelExport.setExportFileName(cs.getCorporateById(corporateId).replace(",", " ").toUpperCase() + "-Employee-Summary-" + ".xls"); excelExport.export(); } }); h.addComponent(exportTableToExcel); h.setComponentAlignment(exportTableToExcel, Alignment.BOTTOM_LEFT); h.setExpandRatio(exportTableToExcel, 3); addComponent(h); addComponent(summary); setExpandRatio(summary, 2); }
From source file:com.openhris.employee.PostEmploymentInfomation.java
public ComponentContainer layout2() { HorizontalLayout hlayout = new HorizontalLayout(); hlayout.setSpacing(true);//from www . java 2 s .c o m hlayout.setWidth("100%"); GridLayout glayout2 = new GridLayout(2, 2); glayout2.setSpacing(true); final PopupDateField endDate = new HRISPopupDateField("Exit Date: "); endDate.setWidth("250px"); endDate.setDateFormat("MM/dd/yyyy"); glayout2.addComponent(endDate, 0, 0); glayout2.setComponentAlignment(endDate, Alignment.BOTTOM_LEFT); Button endDateBtn = new Button("RESIGN"); endDateBtn.setWidth("150px"); endDateBtn.addListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { if (endDate.getValue() == null || endDate.getValue().toString().trim().isEmpty()) { getWindow().showNotification("Enter End Date.", Window.Notification.TYPE_ERROR_MESSAGE); return; } Window window = new ConfirmResignWindow(getEmployeeId(), utilities.convertDateFormat(endDate.getValue().toString().trim().toLowerCase())); if (window.getParent() == null) { getWindow().addWindow(window); } } }); glayout2.addComponent(endDateBtn, 1, 0); glayout2.setComponentAlignment(endDateBtn, Alignment.BOTTOM_LEFT); if (GlobalVariables.getUserRole().equals("administrator") || GlobalVariables.getUserRole().equals("hr")) { endDateBtn.setEnabled(true); } else { endDateBtn.setEnabled(false); } hlayout.addComponent(glayout2); hlayout.setComponentAlignment(glayout2, Alignment.MIDDLE_RIGHT); final PopupDateField entryDateFromEmp = new HRISPopupDateField("Entry Date from Employment: "); entryDateFromEmp.setWidth("250px"); entryDateFromEmp.setDateFormat("MM/dd/yyyy"); entryDateFromEmp.setValue(utilities.parsingDate(employeeService.getEmploymentEntryDate(getEmployeeId()))); glayout2.addComponent(entryDateFromEmp, 0, 1); glayout2.setComponentAlignment(entryDateFromEmp, Alignment.BOTTOM_LEFT); Button entryDateFromEmpBtn = new Button("EDIT"); entryDateFromEmpBtn.setWidth("150px"); entryDateFromEmpBtn.addListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { if (!GlobalVariables.getUserRole().equals("administrator")) { getWindow().showNotification( "You need to be an ADMINISTRATOR to EDIT date entry of employment.", Window.Notification.TYPE_ERROR_MESSAGE); return; } Window sub = new EditEmploymentDateEntryWindow(getEmployeeId(), utilities.convertDateFormat(entryDateFromEmp.getValue().toString())); if (sub.getParent() == null) { getWindow().addWindow(sub); } } }); glayout2.addComponent(entryDateFromEmpBtn, 1, 1); glayout2.setComponentAlignment(entryDateFromEmpBtn, Alignment.BOTTOM_LEFT); if (GlobalVariables.getUserRole().equals("administrator") || GlobalVariables.getUserRole().equals("hr")) { entryDateFromEmpBtn.setEnabled(true); } else { entryDateFromEmpBtn.setEnabled(false); } return hlayout; }
From source file:com.openhris.payroll.contributions.AFLUI.java
public AFLUI(int branchId) { this.branchId = branchId; setSizeFull();//from w ww . j a va2 s. com setSpacing(true); setMargin(new MarginInfo(true, true, false, false)); HorizontalLayout h = new HorizontalLayout(); h.setWidth("100%"); h.setMargin(true); h.setSpacing(true); final PopupDateField payrollDateField = new HRISPopupDateField("Payroll Month and Year"); payrollDateField.setWidth("200px"); h.addComponent(payrollDateField); Button generateBtn = new Button("GENERATE AFL"); generateBtn.setWidth("200px"); generateBtn.addListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { tradeId = cs.getTradeIdByBranchId(getBranchId()); corporateId = cs.getCorporateIdByTradeId(tradeId); afl.setContainerDataSource(new AFLContainer(corporateId, util.parsingDate(util.convertDateFormat(payrollDateField.getValue().toString())))); } }); h.addComponent(generateBtn); h.setComponentAlignment(generateBtn, Alignment.BOTTOM_LEFT); Button exportTableToExcel = new Button("EXPORT TO EXCEL"); exportTableToExcel.setWidth("200px"); exportTableToExcel.addListener(new Button.ClickListener() { private static final long serialVersionUID = -73954695086117200L; private ExcelExport excelExport; @Override public void buttonClick(Button.ClickEvent event) { excelExport = new ExcelExport(afl, "AFL Remitance"); excelExport.excludeCollapsedColumns(); excelExport.setReportTitle(cs.getCorporateById(corporateId).toUpperCase() + " AFL Remitances"); excelExport.setExportFileName( cs.getCorporateById(corporateId).replace(",", " ").toUpperCase() + "-AFL-Remitance-" + util.convertDateFormat(payrollDateField.getValue().toString()) + ".xls"); excelExport.export(); } }); h.addComponent(exportTableToExcel); h.setComponentAlignment(exportTableToExcel, Alignment.BOTTOM_LEFT); h.setExpandRatio(exportTableToExcel, 2); addComponent(h); addComponent(afl); setExpandRatio(afl, 2); }