當前位置: 首頁>>代碼示例>>Java>>正文


Java TextField.addShortcutListener方法代碼示例

本文整理匯總了Java中com.vaadin.ui.TextField.addShortcutListener方法的典型用法代碼示例。如果您正苦於以下問題:Java TextField.addShortcutListener方法的具體用法?Java TextField.addShortcutListener怎麽用?Java TextField.addShortcutListener使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.vaadin.ui.TextField的用法示例。


在下文中一共展示了TextField.addShortcutListener方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createSearchField

import com.vaadin.ui.TextField; //導入方法依賴的package包/類
private TextField createSearchField() {
TextField textFieldSearch = new TextField();
      textFieldSearch.setWidth("30ex");
      textFieldSearch.addShortcutListener(new ShortcutListener("Search", ShortcutAction.KeyCode.ENTER, null) {
	private static final long serialVersionUID = 1L;

	@Override
	public void handleAction(Object sender, Object target) {
		if (target == textFieldSearch) {
			String query = textFieldSearch.getValue();
			Page page = Application.getInstance().createSearchPage(query);
			show(page);
		}
	}
});
      
      return textFieldSearch;
  }
 
開發者ID:BrunoEberhard,項目名稱:minimal-j,代碼行數:19,代碼來源:Vaadin.java

示例2: WebFtsField

import com.vaadin.ui.TextField; //導入方法依賴的package包/類
public WebFtsField() {
    component = new CssLayout();
    component.setPrimaryStyleName(FTS_FIELD_STYLENAME);

    ComponentsFactory cf = AppBeans.get(ComponentsFactory.NAME);
    com.haulmont.cuba.gui.components.TextField searchFieldComponent =
            cf.createComponent(com.haulmont.cuba.gui.components.TextField.class);
    searchField = (TextField) WebComponentsHelper.unwrap(searchFieldComponent);
    searchField.setStyleName("c-ftsfield-text");

    AppUI ui = AppUI.getCurrent();
    if (ui.isTestMode()) {
        searchField.setCubaId("ftsField");
        searchField.setId(ui.getTestIdManager().reserveId("ftsField"));
    }
    searchField.addShortcutListener(new ShortcutListener("fts", com.vaadin.event.ShortcutAction.KeyCode.ENTER, null) {
        @Override
        public void handleAction(Object sender, Object target) {
            openSearchWindow();
        }
    });

    searchBtn = new CubaButton();
    searchBtn.setStyleName("c-ftsfield-button");
    searchBtn.setIcon(WebComponentsHelper.getIcon("app/images/fts-button.png"));
    searchBtn.addClickListener(
            (Button.ClickListener) event -> openSearchWindow()
    );

    component.addComponent(searchField);
    component.addComponent(searchBtn);

    adjustHeight();
    adjustWidth();
}
 
開發者ID:cuba-platform,項目名稱:cuba,代碼行數:36,代碼來源:WebFtsField.java

示例3: createSearchBar

import com.vaadin.ui.TextField; //導入方法依賴的package包/類
private MHorizontalLayout createSearchBar() {
    Label header = new Label("Bookery");
    header.addStyleName(ValoTheme.LABEL_BOLD);
    header.setSizeUndefined();
    header.addStyleName(ValoTheme.LABEL_H3);
    
    searchText = new TextField();
    searchText.setIcon(FontAwesome.SEARCH);
    searchText.addStyleName(ValoTheme.TEXTFIELD_LARGE);
    searchText.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON);
    searchText.setWidth(100, Unit.PERCENTAGE);
    searchText.setInputPrompt("hier einfach suchen..");
    Button searchButton = new Button("such!", new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            Navigator navigator = ((App)UI.getCurrent()).getNavigator();
            if (navigator.getState().contains("search")) {
                navigator.navigateTo(navigator.getState());
            }
            else {
                navigator.navigateTo(SearchView.id);
            }
            
        }
    });
    searchButton.addStyleName(ValoTheme.BUTTON_LARGE);
    searchText.addShortcutListener(new Button.ClickShortcut(searchButton, ShortcutAction.KeyCode.ENTER));

    MHorizontalLayout layout = new MHorizontalLayout(header,searchText,searchButton);
    layout.setWidth(100, Unit.PERCENTAGE);
    layout.setExpandRatio(searchText, 1.0f);
    return layout;
}
 
開發者ID:felixhusse,項目名稱:bookery,代碼行數:34,代碼來源:AppHeader.java

示例4: VaadinQueryContent

import com.vaadin.ui.TextField; //導入方法依賴的package包/類
public VaadinQueryContent() {
	setWidth("100%");
	
	label = new Label();
	if (Resources.isAvailable("Application.queryCaption")) {
		label.setCaption(Resources.getString("Application.queryCaption"));
	}
	label.addStyleName("queryContentLabel");
	addComponent(label);

	textField = new TextField();
	textField.setWidth("600px");
	textField.addShortcutListener(new ShortcutListener("Query", ShortcutAction.KeyCode.ENTER, null) {
		private static final long serialVersionUID = 1L;
		
		@Override
		public void handleAction(Object sender, Object target) {
			if (target == textField) {
				String query = textField.getValue();
				Page page = Application.getInstance().createSearchPage(query);
				Frontend.show(page);
			}
		}
	});
	addComponent(textField);
	setComponentAlignment(textField, Alignment.MIDDLE_CENTER);
}
 
開發者ID:BrunoEberhard,項目名稱:minimal-j,代碼行數:28,代碼來源:VaadinQueryContent.java

示例5: buildFilter

import com.vaadin.ui.TextField; //導入方法依賴的package包/類
private Component buildFilter() {
    final TextField filter = new TextField();
    filter.addTextChangeListener(new TextChangeListener() {
        @Override
        public void textChange(final TextChangeEvent event) {
            Filterable data = (Filterable) table.getContainerDataSource();
            data.removeAllContainerFilters();
            data.addContainerFilter(new Filter() {
                @Override
                public boolean passesFilter(final Object itemId,
                        final Item item) {

                    if (event.getText() == null
                            || event.getText().equals("")) {
                        return true;
                    }

                    return filterByProperty("country", item,
                            event.getText())
                            || filterByProperty("city", item,
                                    event.getText())
                            || filterByProperty("title", item,
                                    event.getText());

                }

                @Override
                public boolean appliesToProperty(final Object propertyId) {
                    if (propertyId.equals("country")
                            || propertyId.equals("city")
                            || propertyId.equals("title")) {
                        return true;
                    }
                    return false;
                }
            });
        }
    });

    filter.setInputPrompt("Filter");
    filter.setIcon(FontAwesome.SEARCH);
    filter.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON);
    filter.addShortcutListener(new ShortcutListener("Clear",
            KeyCode.ESCAPE, null) {
        @Override
        public void handleAction(final Object sender, final Object target) {
            filter.setValue("");
            ((Filterable) table.getContainerDataSource())
                    .removeAllContainerFilters();
        }
    });
    return filter;
}
 
開發者ID:mcollovati,項目名稱:vaadin-vertx-samples,代碼行數:54,代碼來源:TransactionsView.java


注:本文中的com.vaadin.ui.TextField.addShortcutListener方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。