本文整理匯總了Java中javafx.scene.control.TextInputDialog.initOwner方法的典型用法代碼示例。如果您正苦於以下問題:Java TextInputDialog.initOwner方法的具體用法?Java TextInputDialog.initOwner怎麽用?Java TextInputDialog.initOwner使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javafx.scene.control.TextInputDialog
的用法示例。
在下文中一共展示了TextInputDialog.initOwner方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: showLineJumpDialog
import javafx.scene.control.TextInputDialog; //導入方法依賴的package包/類
private void showLineJumpDialog() {
TextInputDialog dialog = new TextInputDialog();
dialog.setTitle("Goto Line");
dialog.getDialogPane().setContentText("Input Line Number: ");
dialog.initOwner(area.getValue().getScene().getWindow());
TextField tf = dialog.getEditor();
int lines = StringUtil.countLine(area.getValue().getText());
ValidationSupport vs = new ValidationSupport();
vs.registerValidator(tf, Validator.<String> createPredicateValidator(
s -> TaskUtil.uncatch(() -> MathUtil.inRange(Integer.valueOf(s), 1, lines)) == Boolean.TRUE,
String.format("Line number must be in [%d,%d]", 1, lines)));
dialog.showAndWait().ifPresent(s -> {
if (vs.isInvalid() == false) {
area.getValue().moveTo(Integer.valueOf(s) - 1, 0);
}
});
}
示例2: openIntInputDialog
import javafx.scene.control.TextInputDialog; //導入方法依賴的package包/類
/**
* show a dialog box to input an integer
*/
public static void openIntInputDialog(String title, String header, String message, int defaultVal, Consumer<Integer> callback) {
TextInputDialog dialog = new TextInputDialog(""+defaultVal);
Stage parent = GuiMode.getPrimaryStage(); // owner is null if JavaFX not fully loaded yet
if(parent != null && parent.getOwner() != null) {
dialog.initOwner(parent.getOwner());
}
dialog.setTitle(title);
dialog.setHeaderText(header);
dialog.setContentText(message);
dialog.showAndWait().ifPresent((text) -> {
int val = defaultVal;
try {
val = Integer.parseInt(text);
} catch(NumberFormatException ignored) {
}
callback.accept(val);
});
}
示例3: openDoubleInputDialog
import javafx.scene.control.TextInputDialog; //導入方法依賴的package包/類
/**
* show a dialog box to input a double
*/
public static void openDoubleInputDialog(String title, String header, String message, double defaultVal, Consumer<Double> callback) {
TextInputDialog dialog = new TextInputDialog(""+defaultVal);
Stage parent = GuiMode.getPrimaryStage(); // owner is null if JavaFX not fully loaded yet
if(parent != null && parent.getOwner() != null) {
dialog.initOwner(parent.getOwner());
}
dialog.setTitle(title);
dialog.setHeaderText(header);
dialog.setContentText(message);
dialog.showAndWait().ifPresent((text) -> {
double val = defaultVal;
try {
val = Double.parseDouble(text);
} catch(NumberFormatException ignored) {
}
callback.accept(val);
});
}
示例4: askNameFX
import javafx.scene.control.TextInputDialog; //導入方法依賴的package包/類
/**
* Ask for a new building name using TextInputDialog in JavaFX/8
* @return new name
*/
public String askNameFX(String oldName) {
String newName = null;
TextInputDialog dialog = new TextInputDialog(oldName);
dialog.initOwner(desktop.getMainScene().getStage());
dialog.initModality(Modality.APPLICATION_MODAL);
dialog.setTitle(Msg.getString("BuildingPanel.renameBuilding.dialogTitle"));
dialog.setHeaderText(Msg.getString("BuildingPanel.renameBuilding.dialog.header"));
dialog.setContentText(Msg.getString("BuildingPanel.renameBuilding.dialog.content"));
Optional<String> result = dialog.showAndWait();
//result.ifPresent(name -> {});
if (result.isPresent()){
//logger.info("The settlement name has been changed to : " + result.get());
newName = result.get();
}
return newName;
}
示例5: changeBranchCoefficient
import javafx.scene.control.TextInputDialog; //導入方法依賴的package包/類
/**
* 分岐點係數を変更する
*
* @param event ActionEvent
*/
@FXML
void changeBranchCoefficient(ActionEvent event) {
TextInputDialog dialog = new TextInputDialog(Double.toString(this.branchCoefficient));
dialog.getDialogPane().getStylesheets().add("logbook/gui/application.css");
dialog.initOwner(this.getScene().getWindow());
dialog.setTitle("分岐點係數を変更");
dialog.setHeaderText("分岐點係數を數値で入力してください 例)\n"
+ SeaArea.沖ノ島沖 + " H,Iマス 係數: 1.0\n"
+ SeaArea.北方AL海域 + " Gマス 係數: 4.0\n"
+ SeaArea.中部海域哨戒線 + " E,Fマス 係數: 4.0\n"
+ SeaArea.MS諸島沖 + " F,Hマス 係數: 3.0\n"
+ SeaArea.グアノ環礁沖海域 + " Hマス 係數: 3.0");
val result = dialog.showAndWait();
if (result.isPresent()) {
String value = result.get();
if (!value.isEmpty()) {
try {
this.branchCoefficient = Double.parseDouble(value);
this.setDecision33();
} catch (NumberFormatException e) {
}
}
}
}
示例6: openTextInputDialog
import javafx.scene.control.TextInputDialog; //導入方法依賴的package包/類
/**
* show a dialog box to input some text
*/
public static void openTextInputDialog(String title, String header, String message, String defaultText, Consumer<String> callback) {
TextInputDialog dialog = new TextInputDialog(defaultText);
Stage parent = GuiMode.getPrimaryStage(); // owner is null if JavaFX not fully loaded yet
if(parent != null && parent.getOwner() != null) {
dialog.initOwner(parent.getOwner());
}
setDialogBoxIcon(dialog);
dialog.setTitle(title);
dialog.setHeaderText(header);
dialog.setContentText(message);
dialog.showAndWait().ifPresent(callback);
}
示例7: addLabel
import javafx.scene.control.TextInputDialog; //導入方法依賴的package包/類
@FXML
void addLabel() {
TextInputDialog dialog = new TextInputDialog("");
dialog.initOwner(this.getScene().getWindow());
dialog.setTitle("艦娘にラベルを追加");
dialog.setHeaderText("ラベルを追加");
TextFields.bindAutoCompletion(dialog.getEditor(), new SuggestSupport(this.labelValue.getItems()));
val result = dialog.showAndWait();
if (result.isPresent()) {
String label = result.get();
if (!label.isEmpty()) {
val labelMap = ShipLabelCollection.get()
.getLabels();
val selections = this.table.getSelectionModel()
.getSelectedItems();
for (ShipItem ship : selections) {
ship.labelProperty().get()
.add(label);
val labels = labelMap.computeIfAbsent(ship.getId(), k -> new LinkedHashSet<>());
labels.add(label);
}
this.updateLabel();
this.table.refresh();
}
}
}