本文整理汇总了Java中javafx.scene.control.TextField.setPromptText方法的典型用法代码示例。如果您正苦于以下问题:Java TextField.setPromptText方法的具体用法?Java TextField.setPromptText怎么用?Java TextField.setPromptText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.control.TextField
的用法示例。
在下文中一共展示了TextField.setPromptText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: SearchBox
import javafx.scene.control.TextField; //导入方法依赖的package包/类
public SearchBox() {
setId("SearchBox");
getStyleClass().add("search-box");
setMinHeight(24);
setPrefSize(200, 24);
setMaxSize(Control.USE_PREF_SIZE, Control.USE_PREF_SIZE);
textBox = new TextField();
textBox.setPromptText("Search");
clearButton = new Button();
clearButton.setVisible(false);
getChildren().addAll(textBox, clearButton);
clearButton.setOnAction(new EventHandler<ActionEvent>() {
@Override public void handle(ActionEvent actionEvent) {
textBox.setText("");
textBox.requestFocus();
}
});
textBox.textProperty().addListener(new ChangeListener<String>() {
@Override public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
clearButton.setVisible(textBox.getText().length() != 0);
}
});
}
示例2: StringBindingSample
import javafx.scene.control.TextField; //导入方法依赖的package包/类
public StringBindingSample() {
final SimpleDateFormat format = new SimpleDateFormat("mm/dd/yyyy");
final TextField dateField = new TextField();
dateField.setPromptText("Enter a birth date");
dateField.setMaxHeight(TextField.USE_PREF_SIZE);
dateField.setMaxWidth(TextField.USE_PREF_SIZE);
Label label = new Label();
label.textProperty().bind(new StringBinding() {
{
bind(dateField.textProperty());
}
@Override protected String computeValue() {
try {
Date date = format.parse(dateField.getText());
Calendar c = Calendar.getInstance();
c.setTime(date);
Date today = new Date();
Calendar c2 = Calendar.getInstance();
c2.setTime(today);
if (c.get(Calendar.DAY_OF_YEAR) == c2.get(Calendar.DAY_OF_YEAR) - 1
&& c.get(Calendar.YEAR) == c2.get(Calendar.YEAR)) {
return "You were born yesterday";
} else {
return "You were born " + format.format(date);
}
} catch (Exception e) {
return "Please enter a valid birth date (mm/dd/yyyy)";
}
}
});
VBox vBox = new VBox(7);
vBox.setPadding(new Insets(12));
vBox.getChildren().addAll(label, dateField);
getChildren().add(vBox);
}
示例3: refreshView
import javafx.scene.control.TextField; //导入方法依赖的package包/类
@Override
public void refreshView ()
{
renameLayout.getChildren().clear();
doorname="";
if(getFXController().getLastViewName().matches("views.StackView.*"))
{
doorname = getMyModel().getDataList("").get(getMyModel().getDataList("").size()-1);
}
oldValue = getMyModel().getString("");
TextField front = new TextField(getMyModel().getString(""));
front.setPromptText("Eingabe erforderlich");
Button saveBtn = new Button("Speichern"); // \u270d \u2055 \u2699 \u270E
saveBtn.setId("small");
saveBtn.setOnAction(e ->
{
saveNameAndExit(oldValue, front.getText(), doorname);
});
saveBtn.setOnKeyReleased(e ->
{
if (e.getCode() == KeyCode.ENTER)
saveNameAndExit(oldValue, front.getText(), doorname);
});
front.setOnKeyReleased(e ->
{
if (e.getCode() == KeyCode.ENTER)
{
saveNameAndExit(oldValue, front.getText(), doorname);
}
});
renameLayout.getChildren().addAll(front, saveBtn);
scroller.setContent(renameLayout);
}
示例4: constructContainer
import javafx.scene.control.TextField; //导入方法依赖的package包/类
@Override
public Parent constructContainer()
{
bp.setId("loginviewbg");
list = new ListView<String>();
items = FXCollections.observableArrayList("Philippe Kr�ttli","Irina Deck","Javier Martinez Alvarez","Frithjof Hoppe");
list.setItems(items);
AllFields = new VBox(50);
AllFields.setAlignment(Pos.CENTER);
AllFields.setMaxWidth(300);
AllFields.setPadding(new Insets(20));
SearchUser = new HBox();
Bottom = new HBox();
txtUserName = new TextField();
txtUserName.setMinHeight(50);
txtUserName.setMinWidth(700);
txtUserName.setPromptText("Email-Adresse des Benutzers");
btnSearch = new AppButton("Suchen");
btnAdd = new AppButton("Hinzuf�gen");
back = new BackButton(getFXController(),"Zur�ck");
SearchUser.getChildren().addAll(txtUserName,btnSearch);
Bottom.getChildren().addAll(back,btnAdd);
AllFields.getChildren().addAll(SearchUser,list,Bottom);
bp.setLeft(AllFields);
//btnSearch.setOnAction(e -> getFXController().showView("userlist"));
return bp;
}
示例5: createTextField
import javafx.scene.control.TextField; //导入方法依赖的package包/类
@Override
public TextField createTextField (String holder, double width) {
TextField field = this.createTextField(width);
field.setPromptText(holder);
return field;
}
示例6: TextValidatorSample
import javafx.scene.control.TextField; //导入方法依赖的package包/类
public TextValidatorSample() {
String validatorCss = TextValidatorSample.class.getResource("Validators.css").toExternalForm();
TextField dateField = new TextField();
dateField.setPromptText("Enter a Large Number");
dateField.setMaxHeight(TextField.USE_PREF_SIZE);
TextInputValidatorPane<TextField> pane = new TextInputValidatorPane<TextField>();
pane.setContent(dateField);
pane.setValidator(new Validator<TextField>() {
public ValidationResult validate(TextField control) {
try {
String text = control.getText();
if (text == null || text.trim().equals("")) return null;
double d = Double.parseDouble(text);
if (d < 1000) {
return new ValidationResult("Should be > 1000", ValidationResult.Type.WARNING);
}
return null; // succeeded
} catch (Exception e) {
// failed
return new ValidationResult("Bad number", ValidationResult.Type.ERROR);
}
}
});
StackPane rootSP = new StackPane();
rootSP.setPadding(new Insets(12));
rootSP.getChildren().add(pane);
pane.getStylesheets().add(validatorCss);
getChildren().add(rootSP);
}
示例7: constructContainer
import javafx.scene.control.TextField; //导入方法依赖的package包/类
@Override
public Parent constructContainer()
{
bp.setId("loginviewbg");
AllFields = new HBox(50);
AllFields.setAlignment(Pos.CENTER);
AllFields.setMaxWidth(300);
AllFields.setPadding(new Insets(20));
AllFields.setPadding(new Insets(200,0,0,0));
//AllFields.setMinWidth(740);
Value = new VBox();
Value.setMinWidth(400);
Value.setSpacing(35);
Buttons = new VBox();
Buttons.setSpacing(5);
Name = new HBox();
inputName = new TextField();
inputName.setPromptText("Names der Door");
inputName.setAlignment(Pos.CENTER_LEFT);
inputName.setMinWidth(50);
name = new Label("Name");
removeDoor = new Label("Door l�schen");
removeStacks = new Label("Enfert den/die Stack/s der Door");
titel = new Label("Bearbeiten");
btnRemoveDoor = new AppButton("Entfernen");
btnRemoveStack = new AppButton("L�schen");
btnModify = new AppButton("�ndern");
back = new BackButton(getFXController(),"Abbrechen");
//Buttons.getChildren().addAll(,,btnRemoveStack,back);
Name.getChildren().addAll(name,inputName);
Value.getChildren().addAll(Name,removeDoor,removeStacks);
Buttons.getChildren().addAll(btnModify,btnRemoveStack,btnRemoveDoor,back);
AllFields.getChildren().addAll(Value,Buttons);
/*inside.setLeft(AllFields);
inside.setRight(Buttons);*/
bp.setCenter(AllFields);
/*
btnCreate.setOnAction(e -> getFXController().showView("serverdoorview"));
--Listenter to crete a door
*/
return bp;
}
示例8: showUsers
import javafx.scene.control.TextField; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public void showUsers()
{
primaryStage = new Stage();
primaryStage.setTitle("e-Tracker Users");
primaryStage.setResizable(false);
primaryStage.initModality(Modality.APPLICATION_MODAL);
primaryStage.getIcons().add(new Image("/pic/slogo.png"));
//name
namecol = new TableColumn<>("Username");
namecol.setMinWidth(250);
namecol.setCellValueFactory(new PropertyValueFactory<>("name"));//has to be the same as in the UserCreation class
//level
levelcol = new TableColumn<>("User Level");
levelcol.setMinWidth(250);
levelcol.setCellValueFactory(new PropertyValueFactory<>("level"));
table= new TableView<>();
table.setItems(getProduct());
table.getColumns().addAll(namecol, levelcol);
table.getSelectionModel().selectedItemProperty().addListener(
(observable, oldValue, newValue) -> showPersonDetails(newValue));
txtname= new TextField();
txtname.setEditable(false);
txtname.setPromptText("Username");
txtlevel= new TextField();
txtlevel.setEditable(false);
txtlevel.setPromptText("User Level e.g. Admin");
badd= new Button("Add...");
badd.setOnAction(e ->{
addClicked();
});
bdel= new Button("Delete");
bdel.setOnAction(e ->{
deleteClicked();
});
bedit= new Button("Edit...");
bedit.setOnAction( e ->{
setPressbEdit();
});
HBox layout2= new HBox();
layout2.setSpacing(10); //similar to that 10
//layout2.setPadding(new Insets(20,20,20,20));
layout2.getChildren().addAll(txtname, txtlevel, bedit, badd, bdel);
layout2.setAlignment(Pos.CENTER_RIGHT);
VBox layout = new VBox(12);
layout.getChildren().addAll(table, layout2);
layout.setPadding(new Insets(20,20,20,20));
layout.setStyle("-fx-background-color: linear-gradient(#E4E9A9, #9CD777);");
Scene scene= new Scene(layout);
scene.getStylesheets().add(Users.class.getResource("users.css").toExternalForm());
primaryStage.setScene(scene);
if(MainWindow.ladmins.getText().equals("User") || MainWindow.ladmins.getText().equals("Office Admin") ||
MainWindow.ladmins.getText().equals("Gate Admin"))
{
badd.setDisable(true);
bdel.setDisable(true);
bedit.setDisable(true);
}
}
示例9: constructContainer
import javafx.scene.control.TextField; //导入方法依赖的package包/类
@Override
public Parent constructContainer()
{
bp = new BorderPane();
bp.setId("userviewbg");
back = new BackButton(getFXController(),"Zur�ck");
tabPane = new TabPane();
tabPane.setTabClosingPolicy(TabClosingPolicy.UNAVAILABLE);
tabPane.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<Tab>() {
@Override
public void changed(ObservableValue<? extends Tab> ov, Tab tabOld, Tab tabNew) {
refreshView();
}
});
Center = new VBox();
Search = new HBox();
Top = new VBox();
txtSearch = new TextField();
txtSearch.setPromptText("Suche nach Doors");
txtSearch.setMinWidth(740);
txtSearch.setMinHeight(50);;
btnSearch = new AppButton("Suchen");
btnCreate = new AppButton("++Erstellen++");
btnCreate.setMinWidth(590);
btnCreate.setOnAction(e -> getFXController().showView("createdoorview"));
StackShowList.setSpacing(20);
Center.setSpacing(20);
sMain = new ScrollPane();
sMain.setContent(Center);
Search.getChildren().addAll(txtSearch,btnSearch);
Center.getChildren().addAll(StackShowList,btnCreate);
back = new AppButton("Zur�ck");
back.setOnAction(e-> getFXController().showView("saveuploadstackonserverdialogview"));
Bottom = new VBox();
Bottom.getChildren().addAll(back);
Top.getChildren().addAll(Search,tabPane);
bp.setTop(Top);
bp.setCenter(sMain);
bp.setBottom(Bottom);
getFXController().getModel("serverstack").registerView(this);
return bp;
}
开发者ID:CoffeeCodeSwitzerland,项目名称:Lernkartei_2017,代码行数:60,代码来源:SaveDownloadstackOwnDMODoorSelectionView.java
示例10: randomDeviceStatus
import javafx.scene.control.TextField; //导入方法依赖的package包/类
public static Optional<TcpMsgResponseRandomDeviceStatus> randomDeviceStatus() throws NumberFormatException {
Dialog<TcpMsgResponseRandomDeviceStatus> dialog = new Dialog<>();
dialog.setTitle("随机状态信息");
dialog.setHeaderText("随机设备的状态信息");
ButtonType loginButtonType = new ButtonType("发送", ButtonBar.ButtonData.OK_DONE);
dialog.getDialogPane().getButtonTypes().addAll(loginButtonType, ButtonType.CANCEL);
// Create the username and password labels and fields.
GridPane grid = new GridPane();
grid.setHgap(10);
grid.setVgap(10);
grid.setPadding(new Insets(20, 150, 10, 10));
TextField textFieldGroupId = new TextField();
textFieldGroupId.setPromptText("1 - 120");
TextField textFieldLength = new TextField();
textFieldLength.setPromptText("1 - 60_0000");
TextField textFieldStatus = new TextField();
textFieldStatus.setPromptText("1 - 6");
grid.add(new Label("组号: "), 0, 0);
grid.add(textFieldGroupId, 1, 0);
grid.add(new Label("范围: "), 0, 1);
grid.add(textFieldLength, 1, 1);
grid.addRow(2, new Label("状态码: "));
// grid.add(, 0, 2);
grid.add(textFieldStatus, 1, 2);
// Enable/Disable login button depending on whether a username was entered.
Node loginButton = dialog.getDialogPane().lookupButton(loginButtonType);
loginButton.setDisable(true);
// Do some validation (using the Java 8 lambda syntax).
textFieldGroupId.textProperty().addListener((observable, oldValue, newValue) -> loginButton.setDisable(fieldisEmpty(textFieldGroupId, textFieldLength, textFieldStatus)));
textFieldLength.textProperty().addListener((observable, oldValue, newValue) -> loginButton.setDisable(fieldisEmpty(textFieldGroupId, textFieldLength, textFieldStatus)));
textFieldStatus.textProperty().addListener((observable, oldValue, newValue) -> loginButton.setDisable(fieldisEmpty(textFieldGroupId, textFieldLength, textFieldStatus)));
dialog.getDialogPane().setContent(grid);
// Request focus on the username field by default.
Platform.runLater(textFieldGroupId::requestFocus);
dialog.setResultConverter(dialogButton -> {
if (dialogButton == loginButtonType) {
try {
TcpMsgResponseRandomDeviceStatus tcpMsgResponseDeviceStatus = new TcpMsgResponseRandomDeviceStatus(Integer.parseInt(
textFieldGroupId.getText().trim()),
Integer.parseInt(textFieldStatus.getText().trim()),
Integer.parseInt(textFieldLength.getText().trim()));
return tcpMsgResponseDeviceStatus;
} catch (NumberFormatException e) {
System.out.println("空");
return new TcpMsgResponseRandomDeviceStatus(-1, -1, -1);
}
}
return null;
});
return dialog.showAndWait();
}
示例11: constructContainer
import javafx.scene.control.TextField; //导入方法依赖的package包/类
@Override
public Parent constructContainer()
{
bp.setId("loginviewbg");
Errorbox = new HBox(50);
Errorbox.setAlignment(Pos.CENTER);
Errorbox.setPadding(new Insets(20));
AllFields = new VBox(50);
AllFields.setAlignment(Pos.CENTER);
AllFields.setMaxWidth(300);
AllFields.setPadding(new Insets(20));
Controls = new HBox(50);
Controls.setAlignment(Pos.CENTER);
Controls.setPadding(new Insets(20));
txtName = new TextField();
txtName.setPromptText("Username");
pwPassword = new PasswordField();
pwPassword.setPromptText("Passwort");
;
home = new HomeButton(getFXController());
reg = new AppButton("Noch kein Profil?");
log = new AppButton("Login");
errorText = new Label("");
Errorbox.getChildren().addAll(errorText);
Controls.getChildren().addAll(home, reg);
AllFields.getChildren().addAll(txtName, pwPassword, log);
bp.setTop(Errorbox);
bp.setCenter(AllFields);
bp.setBottom(Controls);
reg.setOnAction(e -> getFXController().showView("registerview"));
log.setOnAction(e ->
{
// So that you can always check again who was logged in last,
// but if user logged in, it should be set as ""
Globals.lastRegisteredUser = "";
String name = txtName.getText();
String password = pwPassword.getText();
// So that entries don't exist after leaving the view
txtName.clear();
pwPassword.clear();
if (name.equals("[email protected]") && BCrypt.checkpw(password, "$2a$12$8hcwdnkJ7uO3FvDEG/1fv.vaSNI/FfZqEzfUZFUYRUHLzRjkV/Z5.")/*plaintext-password: "gibb"*/)
{
Globals.username = name;
getFXController().showView("managementselectionview");
} else
{
Alert alert = new Alert(AlertType.ERROR);
alert.setTitle("Fehler 0x0001");
alert.setHeaderText("Login-Daten inkorrekt.");
alert.setContentText(
"Benutzername und Passwort stimmen nicht �berein oder existieren nicht.\nStellen Sie sicher, dass Ihre Eingaben korrekt sind.");
pwPassword.clear();
txtName.clear();
alert.showAndWait();
}
});
return bp;
}
示例12: showBucketAddableDialog
import javafx.scene.control.TextField; //导入方法依赖的package包/类
public void showBucketAddableDialog() {
ButtonType ok = new ButtonType(Values.OK, ButtonData.OK_DONE);
Dialog<String[]> dialog = getDialog(ok);
TextField bucket = new TextField();
bucket.setPromptText(Values.BUCKET_NAME);
TextField url = new TextField();
url.setPromptText(Values.BUCKET_URL);
// TextField zone = new TextField();
ComboBox<String> zone = new ComboBox<String>();
zone.getItems().addAll(Values.BUCKET_NAME_ARRAY);
zone.setValue(Values.BUCKET_NAME_ARRAY[0]);
GridPane grid = getGridPane();
grid.add(new Label(Values.BUCKET_NAME), 0, 0);
grid.add(bucket, 1, 0);
grid.add(new Label(Values.BUCKET_URL), 0, 1);
grid.add(url, 1, 1);
grid.add(new Label(Values.BUCKET_ZONE_NAME), 0, 2);
grid.add(zone, 1, 2);
Node okButton = dialog.getDialogPane().lookupButton(ok);
okButton.setDisable(true);
// 监听文本框的输入状态
bucket.textProperty().addListener((observable, oldValue, newValue) -> {
okButton.setDisable(newValue.trim().isEmpty() || url.getText().isEmpty());
});
url.textProperty().addListener((observable, oldValue, newValue) -> {
okButton.setDisable(newValue.trim().isEmpty() || bucket.getText().isEmpty());
});
dialog.getDialogPane().setContent(grid);
Platform.runLater(() -> bucket.requestFocus());
dialog.setResultConverter(dialogButton -> {
if (dialogButton == ok) {
return new String[] { bucket.getText(),
zone.getValue() + " " + (Checker.isHyperLink(url.getText()) ? url.getText() : "example.com") };
}
return null;
});
Optional<String[]> result = dialog.showAndWait();
result.ifPresent(res -> {
logger.info("bucket name: " + res[0] + ", zone name: " + res[1]);
Platform.runLater(() -> MainWindowController.getInstance().addItem(res[0]));
QiniuApplication.buckets.put(res[0], res[1]);
ConfigLoader.writeConfig();
});
}
示例13: createTextField
import javafx.scene.control.TextField; //导入方法依赖的package包/类
public static TextField createTextField(String promptText)
{
TextField field = new TextField();
field.setPromptText(promptText);
return field;
}
示例14: constructContainer
import javafx.scene.control.TextField; //导入方法依赖的package包/类
@Override
public Parent constructContainer()
{
bp.setId("loginviewbg");
list = new ListView<String>();
items = FXCollections.observableArrayList("Philippe Kr�ttli","Irina Deck","Javier Martinez Alvarez","Frithjof Hoppe");
list.setItems(items);
AllFields = new VBox(50);
AllFields.setAlignment(Pos.CENTER);
AllFields.setMaxWidth(300);
AllFields.setPadding(new Insets(20));
CheckGroup = new HBox(50);
ShowStatus = new HBox(50);
Option = new HBox(50);
txtGroupName = new TextField();
txtGroupName.setPromptText("Gruppenname");
name = new Label("Name:");
status = new Label("Status");
statusValue = new Label("{Verf�gbarkeitsstatus}");
btnCheck = new AppButton("Pr�fen");
btnAdd = new AppButton("Hinzuf�gen");
btnRemove = new AppButton("Entfernen");
back = new BackButton(getFXController(),"Zur�ck");
AllFields.getChildren().addAll(CheckGroup,ShowStatus,Option,list);
CheckGroup.getChildren().addAll(name,txtGroupName,btnCheck);
ShowStatus.getChildren().addAll(status,statusValue);
Option.getChildren().addAll(back,btnAdd,btnRemove);
bp.setCenter(AllFields);
btnAdd.setOnAction(e -> getFXController().showView("userlistview"));
back.setOnAction(e -> getFXController().showView("groupview"));
/*Has to check if name of group already exists*/
btnCheck.setOnAction(e -> getFXController().showView(""));
return bp;
}
示例15: constructContainer
import javafx.scene.control.TextField; //导入方法依赖的package包/类
@Override
public Parent constructContainer()
{
bp = new BorderPane();
bp.setId("userviewbg");
back = new BackButton(getFXController(),"Zur�ck");
tabPane = new TabPane();
tabPane.setTabClosingPolicy(TabClosingPolicy.UNAVAILABLE);
tabPane.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<Tab>() {
@Override
public void changed(ObservableValue<? extends Tab> ov, Tab tabOld, Tab tabNew) {
refreshView();
}
});
Center = new VBox();
Search = new HBox();
Top = new VBox();
txtSearch = new TextField();
txtSearch.setPromptText("Suche nach Doors");
txtSearch.setMinWidth(740);
txtSearch.setMinHeight(50);;
btnSearch = new AppButton("Suchen");
btnCreate = new AppButton("++Erstellen++");
btnCreate.setMinWidth(590);
btnCreate.setOnAction(e -> getFXController().showView("createdoorview"));
StackShowList.setSpacing(20);
Center.setSpacing(20);
sMain = new ScrollPane();
sMain.setContent(Center);
Search.getChildren().addAll(txtSearch,btnSearch);
Center.getChildren().addAll(StackShowList,btnCreate);
back = new AppButton("Zur�ck");
back.setOnAction(e-> getFXController().showView("savedownloadstackowndmodoorselectionview"));
Bottom = new VBox();
Bottom.getChildren().addAll(back);
Top.getChildren().addAll(Search,tabPane);
bp.setTop(Top);
bp.setCenter(sMain);
bp.setBottom(Bottom);
getFXController().getModel("serverstack").registerView(this);
return bp;
}