本文整理匯總了Java中com.vaadin.ui.TextField.focus方法的典型用法代碼示例。如果您正苦於以下問題:Java TextField.focus方法的具體用法?Java TextField.focus怎麽用?Java TextField.focus使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.vaadin.ui.TextField
的用法示例。
在下文中一共展示了TextField.focus方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: initInputField
import com.vaadin.ui.TextField; //導入方法依賴的package包/類
protected void initInputField() {
// Csslayout is used to style inputtext as rounded
CssLayout csslayout = new CssLayout();
csslayout.setHeight(24, UNITS_PIXELS);
csslayout.setWidth(100, UNITS_PERCENTAGE);
layout.addComponent(csslayout);
inputField = new TextField();
inputField.setWidth(100, UNITS_PERCENTAGE);
inputField.addStyleName(ExplorerLayout.STYLE_SEARCHBOX);
inputField.setInputPrompt(i18nManager.getMessage(Messages.TASK_CREATE_NEW));
inputField.focus();
csslayout.addComponent(inputField);
layout.setComponentAlignment(csslayout, Alignment.MIDDLE_LEFT);
layout.setExpandRatio(csslayout, 1.0f);
}
示例2: initSearchField
import com.vaadin.ui.TextField; //導入方法依賴的package包/類
protected void initSearchField() {
HorizontalLayout searchLayout = new HorizontalLayout();
searchLayout.setSpacing(true);
addComponent(searchLayout);
// textfield
searchField = new TextField();
searchField.setInputPrompt(i18nManager.getMessage(Messages.PEOPLE_SEARCH));
searchField.setWidth(180, UNITS_PIXELS);
searchField.focus();
searchLayout.addComponent(searchField);
// Logic to change table according to input
searchField.addListener(new TextChangeListener() {
public void textChange(TextChangeEvent event) {
searchPeople(event.getText());
}
});
initSelectMyselfButton(searchLayout);
}
示例3: initFilterRow
import com.vaadin.ui.TextField; //導入方法依賴的package包/類
private void initFilterRow(Column<Application, String> appColumn, Column<Application, String> envColumn, Column<Application, String> urlColumn) {
TextField filterApp = new TextField();
TextField filterEnv = new TextField();
TextField filterUrl = new TextField();
filterApp.setPlaceholder("filter by application...");
filterApp.addValueChangeListener(e -> updateApplications(e.getValue(), filterEnv.getValue(), filterUrl.getValue()));
filterApp.setValueChangeMode(ValueChangeMode.LAZY);
filterApp.focus();
filterApp.setSizeFull();
filterEnv.setPlaceholder("filter by environment...");
filterEnv.addValueChangeListener(e -> updateApplications(filterApp.getValue(), e.getValue(), filterUrl.getValue()));
filterEnv.setValueChangeMode(ValueChangeMode.LAZY);
filterEnv.setSizeFull();
filterUrl.setPlaceholder("filter by URL...");
filterUrl.addValueChangeListener(e -> updateApplications(filterApp.getValue(), filterEnv.getValue(), e.getValue()));
filterUrl.setValueChangeMode(ValueChangeMode.LAZY);
filterUrl.setSizeFull();
// Header row
HeaderRow filterRow = grid.addHeaderRowAt(grid.getHeaderRowCount());
filterRow.getCell(appColumn).setComponent(filterApp);
filterRow.getCell(envColumn).setComponent(filterEnv);
filterRow.getCell(urlColumn).setComponent(filterUrl);
}
示例4: addForm
import com.vaadin.ui.TextField; //導入方法依賴的package包/類
private void addForm() {
FormLayout loginForm = new FormLayout();
MessageProvider mp = ServiceContextManager.getServiceContext().getService(MessageProvider.class);
username = new TextField(mp.getMessage("default.label.username"));
password = new PasswordField(mp.getMessage("default.label.password"));
loginForm.addComponents(username, password);
addComponent(loginForm);
loginForm.setSpacing(true);
for(Component component:loginForm){
component.setWidth("100%");
}
username.focus();
}
示例5: initUrl
import com.vaadin.ui.TextField; //導入方法依賴的package包/類
protected void initUrl() {
TextField urlField = new TextField(i18nManager.getMessage(Messages.RELATED_CONTENT_TYPE_URL_URL));
urlField.focus();
urlField.setRequired(true);
urlField.setRequiredError(i18nManager.getMessage(Messages.RELATED_CONTENT_TYPE_URL_URL_REQUIRED));
urlField.setWidth(100, UNITS_PERCENTAGE);
// URL isn't mutable once attachment is created
if(attachment != null) {
urlField.setEnabled(false);
}
addField("url", urlField);
}
示例6: initName
import com.vaadin.ui.TextField; //導入方法依賴的package包/類
protected void initName() {
TextField nameField = new TextField(i18nManager.getMessage(Messages.RELATED_CONTENT_NAME));
nameField.focus();
nameField.setRequired(true);
nameField.setRequiredError(i18nManager.getMessage(Messages.RELATED_CONTENT_NAME_REQUIRED));
nameField.setWidth(100, UNITS_PERCENTAGE);
form.addField("name", nameField);
}
示例7: loadUserDetails
import com.vaadin.ui.TextField; //導入方法依賴的package包/類
protected void loadUserDetails() {
// Grid of details
GridLayout detailGrid = new GridLayout();
detailGrid.setColumns(2);
detailGrid.setSpacing(true);
detailGrid.setMargin(true, true, false, true);
userDetailsLayout.addComponent(detailGrid);
// Details
addUserDetail(detailGrid, i18nManager.getMessage(Messages.USER_ID), new Label(user.getId())); // details are non-editable
if (!editingDetails) {
addUserDetail(detailGrid, i18nManager.getMessage(Messages.USER_FIRSTNAME), new Label(user.getFirstName()));
addUserDetail(detailGrid, i18nManager.getMessage(Messages.USER_LASTNAME), new Label(user.getLastName()));
addUserDetail(detailGrid, i18nManager.getMessage(Messages.USER_EMAIL), new Label(user.getEmail()));
} else {
firstNameField = new TextField(null, user.getFirstName() != null ? user.getFirstName() : "");
addUserDetail(detailGrid, i18nManager.getMessage(Messages.USER_FIRSTNAME), firstNameField);
firstNameField.focus();
lastNameField = new TextField(null, user.getLastName() != null ? user.getLastName() : "");
addUserDetail(detailGrid, i18nManager.getMessage(Messages.USER_LASTNAME), lastNameField);
emailField = new TextField(null, user.getEmail() != null ? user.getEmail() : "");
addUserDetail(detailGrid, i18nManager.getMessage(Messages.USER_EMAIL), emailField);
passwordField = new PasswordField();
Label cautionLabel = new Label(i18nManager.getMessage(Messages.USER_RESET_PASSWORD));
cautionLabel.addStyleName(Reindeer.LABEL_SMALL);
HorizontalLayout passwordLayout = new HorizontalLayout();
passwordLayout.setSpacing(true);
passwordLayout.addComponent(passwordField);
passwordLayout.addComponent(cautionLabel);
passwordLayout.setComponentAlignment(cautionLabel, Alignment.MIDDLE_LEFT);
addUserDetail(detailGrid, i18nManager.getMessage(Messages.USER_PASSWORD), passwordLayout);
}
}
示例8: initForm
import com.vaadin.ui.TextField; //導入方法依賴的package包/類
protected void initForm() {
form = new Form();
form.setValidationVisibleOnCommit(true);
form.setImmediate(true);
addComponent(form);
// name
nameField = new TextField(i18nManager.getMessage(Messages.TASK_NAME));
nameField.focus();
nameField.setRequired(true);
nameField.setRequiredError(i18nManager.getMessage(Messages.TASK_NAME_REQUIRED));
form.addField("name", nameField);
// description
descriptionArea = new TextArea(i18nManager.getMessage(Messages.TASK_DESCRIPTION));
descriptionArea.setColumns(25);
form.addField("description", descriptionArea);
// duedate
dueDateField = new DateField(i18nManager.getMessage(Messages.TASK_DUEDATE));
dueDateField.setResolution(DateField.RESOLUTION_DAY);
form.addField("duedate", dueDateField);
// priority
priorityComboBox = new PriorityComboBox(i18nManager);
form.addField("priority", priorityComboBox);
}
示例9: initGrid
import com.vaadin.ui.TextField; //導入方法依賴的package包/類
private void initGrid() {
this.grid = new Grid<>(PropertyItem.class);
this.grid.removeAllColumns();
Column<PropertyItem, String> propertyColumn = this.grid.addColumn(PropertyItem::getKey)
.setCaption("Property")
.setExpandRatio(1);
Column<PropertyItem, String> valueColumn = this.grid.addColumn(PropertyItem::getValue)
.setCaption("Value")
.setExpandRatio(1);
Column<PropertyItem, String> originColumn = this.grid.addColumn(PropertyItem::getOrigin).setCaption("Origin");
this.grid.sort(propertyColumn);
this.grid.setSizeFull();
this.grid.setRowHeight(40);
// distinct origin
List<String> origins = this.currentEnv.getProperties().stream()
.map(PropertyItem::getOrigin)
.distinct()
.sorted(String::compareTo)
.collect(Collectors.toList());
// Filters
TextField filterProperty = new TextField();
TextField filterValue = new TextField();
NativeSelect<String> filterOrigin = new NativeSelect<>(null, origins);
filterProperty.setPlaceholder("filter by key...");
filterProperty.addValueChangeListener(e -> updateProperties(e.getValue(), filterValue.getValue(), filterOrigin.getValue()));
filterProperty.setValueChangeMode(ValueChangeMode.LAZY);
filterProperty.focus();
filterProperty.setSizeFull();
filterValue.setPlaceholder("filter by value...");
filterValue.addValueChangeListener(e -> updateProperties(filterProperty.getValue(), e.getValue(), filterOrigin.getValue()));
filterValue.setValueChangeMode(ValueChangeMode.LAZY);
filterValue.setSizeFull();
filterOrigin.addValueChangeListener(e -> updateProperties(filterProperty.getValue(), filterValue.getValue(), e.getValue()));
filterOrigin.setSizeFull();
// Header row
HeaderRow filterRow = grid.addHeaderRowAt(grid.getHeaderRowCount());
filterRow.getCell(propertyColumn).setComponent(filterProperty);
filterRow.getCell(valueColumn).setComponent(filterValue);
filterRow.getCell(originColumn).setComponent(filterOrigin);
}
示例10: enter
import com.vaadin.ui.TextField; //導入方法依賴的package包/類
@Override
public void enter(ViewChangeEvent event) {
pageHelper.setErrorHandler(this);
this.removeAllComponents();
// Get application
int appId = Integer.parseInt(event.getParameters());
Application app = pageHelper.getApp(appId);
// Get loggers config
Optional<Loggers> loggers = getLoggers(app);
if(loggers.isPresent()) {
// Display loggers in a grid
grid = new Grid<>(LoggerGridRow.class);
grid.removeAllColumns();
Column<LoggerGridRow, String> nameColumn = grid.addColumn(LoggerGridRow::getName)
.setCaption("Name")
.setExpandRatio(2);
grid.addComponentColumn(logger -> {
NativeSelect<String> levelsDropdown = new NativeSelect<>(null, loggers.get().getLevels());
levelsDropdown.setEmptySelectionAllowed(false);
levelsDropdown.setSelectedItem(logger.getLevel());
// on selected level
levelsDropdown.addValueChangeListener(value -> {
// change logger level
loggersService.changeLevel(app, logger.getName(), value.getValue());
// refresh data in grid (several loggers might have been impacted)
updateLoggers(app);
Notification.show(
String.format("Logger %s level changed to %s", logger.getName(), value.getValue())
, Notification.Type.TRAY_NOTIFICATION);
});
return levelsDropdown;
}) .setCaption("Level")
.setExpandRatio(1);
grid.setSizeFull();
grid.setRowHeight(40);
grid.setItems(loggersRows);
grid.sort(nameColumn);
// Filter grid by logger name
filterInput = new TextField();
filterInput.setPlaceholder("filter by logger name...");
filterInput.addValueChangeListener(e -> filterLoggers(e.getValue()));
filterInput.setValueChangeMode(ValueChangeMode.LAZY);
filterInput.focus();
filterInput.setSizeFull();
// Header row
HeaderRow filterRow = grid.addHeaderRowAt(grid.getHeaderRowCount());
filterRow.getCell(nameColumn).setComponent(filterInput);
this.addComponent(new PageHeader(app, "Loggers"));
this.addComponent(new Label("Changing a level will update one/many logger(s) level(s)"));
this.addComponent(grid);
} else {
this.addComponent(new PageHeader(app, "Loggers"));
this.addComponent(new Label(String.format("Failed to call %s<br />This endpoint is available since Spring Boot 1.5", app.endpoints().loggers()), ContentMode.HTML));
}
}
示例11: initAboutSection
import com.vaadin.ui.TextField; //導入方法依賴的package包/類
protected void initAboutSection() {
// Header
HorizontalLayout header = new HorizontalLayout();
header.setWidth(100, UNITS_PERCENTAGE);
header.addStyleName(ExplorerLayout.STYLE_DETAIL_BLOCK);
infoPanelLayout.addComponent(header);
Label aboutLabel = createProfileHeader(infoPanelLayout, i18nManager.getMessage(Messages.PROFILE_ABOUT));
header.addComponent(aboutLabel);
header.setExpandRatio(aboutLabel, 1.0f);
// only show edit/save buttons if current user matches
if (isCurrentLoggedInUser) {
Button actionButton = null;
if (!editable) {
actionButton = initEditProfileButton();
} else {
actionButton = initSaveProfileButton();
}
header.addComponent(actionButton);
header.setComponentAlignment(actionButton, Alignment.MIDDLE_RIGHT);
}
// 'About' fields
GridLayout aboutLayout = createInfoSectionLayout(2, 4);
// Name
if (!editable && (isDefined(user.getFirstName()) || isDefined(user.getLastName()) )) {
addProfileEntry(aboutLayout, i18nManager.getMessage(Messages.PROFILE_NAME), user.getFirstName() + " " + user.getLastName());
} else if (editable) {
firstNameField = new TextField();
firstNameField.focus();
addProfileInputField(aboutLayout, i18nManager.getMessage(Messages.PROFILE_FIRST_NAME), firstNameField, user.getFirstName());
lastNameField = new TextField();
addProfileInputField(aboutLayout, i18nManager.getMessage(Messages.PROFILE_LAST_NAME), lastNameField, user.getLastName());
}
// Job title
if (!editable && isDefined(jobTitle)) {
addProfileEntry(aboutLayout, i18nManager.getMessage(Messages.PROFILE_JOBTITLE), jobTitle);
} else if (editable) {
jobTitleField = new TextField();
addProfileInputField(aboutLayout, i18nManager.getMessage(Messages.PROFILE_JOBTITLE), jobTitleField, jobTitle);
}
// Birthdate
if (!editable && isDefined(birthDate)) {
addProfileEntry(aboutLayout, i18nManager.getMessage(Messages.PROFILE_BIRTHDATE), birthDate);
} else if (editable) {
birthDateField = new DateField();
birthDateField.setDateFormat(Constants.DEFAULT_DATE_FORMAT);
birthDateField.setResolution(DateField.RESOLUTION_DAY);
try {
birthDateField.setValue(new SimpleDateFormat(Constants.DEFAULT_DATE_FORMAT).parse(birthDate));
} catch (Exception e) {} // do nothing
addProfileInputField(aboutLayout, i18nManager.getMessage(Messages.PROFILE_BIRTHDATE), birthDateField, null);
}
// Location
if (!editable && isDefined(location)) {
addProfileEntry(aboutLayout, i18nManager.getMessage(Messages.PROFILE_LOCATION), location);
} else if (editable) {
locationField = new TextField();
addProfileInputField(aboutLayout, i18nManager.getMessage(Messages.PROFILE_LOCATION), locationField, location);
}
}