本文整理汇总了Java中javafx.scene.control.TextInputDialog.setContentText方法的典型用法代码示例。如果您正苦于以下问题:Java TextInputDialog.setContentText方法的具体用法?Java TextInputDialog.setContentText怎么用?Java TextInputDialog.setContentText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.control.TextInputDialog
的用法示例。
在下文中一共展示了TextInputDialog.setContentText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: kickPlayerAction
import javafx.scene.control.TextInputDialog; //导入方法依赖的package包/类
private void kickPlayerAction(ActionEvent e) {
TextInputDialog dial = new TextInputDialog("No reason indicated");
dial.setTitle("Kick player");
dial.setHeaderText("Do you really want to kick " + player.getName() + " ?");
dial.setContentText("Reason ");
Optional<String> result = dial.showAndWait();
if (result.isPresent()) {
try {
server.kickPlayer(player, result.orElse("No reason indicated"));
} catch (RCONServerException e1) {
server.logError(e1);
}
}
}
示例2: renameProject
import javafx.scene.control.TextInputDialog; //导入方法依赖的package包/类
private boolean renameProject(Project project)
{
TextInputDialog dialog = new TextInputDialog(project.getName());
dialog.setTitle("Rename Project");
dialog.setHeaderText(null);
dialog.setGraphic(null);
dialog.setContentText("Enter a new name for the project:");
Optional<String> result = dialog.showAndWait();
if (result.isPresent())
{
String newName = result.get();
if (newName.equals(project.getName()))
{
showInfoDialogue("The new name must be different from the old name");
return renameProject(project);
}
else
{
project.setName(newName);
}
}
return false;
}
示例3: 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);
});
}
示例4: 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);
});
}
示例5: handleFileNewProject
import javafx.scene.control.TextInputDialog; //导入方法依赖的package包/类
@FXML
private void handleFileNewProject(ActionEvent event) {
TextInputDialog newProjectDialog = new TextInputDialog();
newProjectDialog.setTitle("Create Project");
newProjectDialog.setHeaderText("Create new project");
newProjectDialog.setContentText("Project name:");
newProjectDialog.showAndWait()
.ifPresent(r -> {
Path projectPath = workspaceService.getActiveWorkspace().getWorkingDirectory().resolve(r);
try {
listViewProjects.getItems().add(projectService.create(new ProjectRequest(projectPath)));
} catch (IOException e) {
Alert alert = new Alert(AlertType.ERROR);
alert.setTitle("Create project failed");
alert.setHeaderText("Failed to create new project.");
alert.showAndWait();
// TODO nickavv: create custom "stack trace dialog" to show the actual error
}
});
}
示例6: telaQuantidade
import javafx.scene.control.TextInputDialog; //导入方法依赖的package包/类
/**
* M�TODO QUE ABRE A TELA PARA INSERIR A QUANTIDADE DE PRODUTOS PARA ATENDER A ENCOMENDA
* @return Quantidade de produtos para atender a encomenda
*/
public Integer telaQuantidade(){
TextInputDialog dialog = new TextInputDialog();
dialog.setTitle("BuyMe");
dialog.setHeaderText("Atender encomenda");
dialog.setContentText("Digite a quantidade que deseja atender com essa produ��o: ");
Optional<String> result = dialog.showAndWait();
if (result.isPresent()){
if(Utils.isNumber(result.get())){
return Integer.parseInt(result.get());
}else{
popup.getError("A quantidade deve ser um n�mero!");
return 0;
}
}else{
return 0;
}
}
示例7: showTextInput
import javafx.scene.control.TextInputDialog; //导入方法依赖的package包/类
/**
* Shows a simple dialog that waits for the user to enter some text.
* @param message The message is shown in the content text of the dialog.
* @return The user input
*/
private String showTextInput(String message) {
TextInputDialog dialog = new TextInputDialog();
((Stage)dialog.getDialogPane().getScene().getWindow()).getIcons().add(new Image("file:pictures/icon.png"));
dialog.setTitle("Please input a value");
dialog.setHeaderText(null);
dialog.setContentText(message);
Optional<String> input = dialog.showAndWait();
if (input.isPresent()) {
if (!input.get().isEmpty()) {
return input.get();
} else {
new TDDTDialog("alert", "Missing input");
}
}
return "-1";
}
开发者ID:ProPra16,项目名称:programmierpraktikum-abschlussprojekt-nimmdochirgendeinennamen,代码行数:23,代码来源:TDDTDialog.java
示例8: 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.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 old building name has been changed to: " + result.get());
newName = result.get();
}
return newName;
}
示例9: 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;
}
示例10: changeMapName
import javafx.scene.control.TextInputDialog; //导入方法依赖的package包/类
/**
* Allow changing the default ut4 map name suggested by ut4 converter
*
* @param event
*/
@FXML
private void changeMapName(ActionEvent event) {
TextInputDialog dialog = new TextInputDialog(mapConverter.getOutMapName());
dialog.setTitle("Text Input Dialog");
dialog.setHeaderText("Map Name Change");
dialog.setContentText("Enter UT4 map name:");
// Traditional way to get the response value.
Optional<String> result = dialog.showAndWait();
if (result.isPresent()) {
String newMapName = result.get();
newMapName = T3DUtils.filterName(newMapName);
if (newMapName.length() > 3) {
mapConverter.setOutMapName(newMapName);
outMapNameLbl.setText(mapConverter.getOutMapName());
mapConverter.initConvertedResourcesFolder();
ut4BaseReferencePath.setText(mapConverter.getUt4ReferenceBaseFolder());
}
}
}
示例11: changeRelativeUtMapPath
import javafx.scene.control.TextInputDialog; //导入方法依赖的package包/类
@FXML
private void changeRelativeUtMapPath(ActionEvent event) {
// TODO
TextInputDialog dialog = new TextInputDialog(mapConverter.getOutMapName());
dialog.setTitle("Text Input Dialog");
dialog.setHeaderText("Map Name Change");
dialog.setContentText("Enter UT4 map name:");
// Traditional way to get the response value.
Optional<String> result = dialog.showAndWait();
if (result.isPresent()) {
String newMapName = result.get();
newMapName = T3DUtils.filterName(newMapName);
if (newMapName.length() > 3) {
mapConverter.setOutMapName(newMapName);
outMapNameLbl.setText(mapConverter.getOutMapName());
}
}
}
示例12: showNewTabColumnsDialog
import javafx.scene.control.TextInputDialog; //导入方法依赖的package包/类
/**
* Third entry. This if it returns a value actually creates the tab
*/
void showNewTabColumnsDialog(String name, int rows) {
logger.info("showNewTabColumnsDialog was called with the data: " + name + " & " + rows);
if (rows > 0) {
finishNewTabDialogs(rows, 0, name);
return;
}
TextInputDialog inputDialog = new TextInputDialog();
inputDialog.setContentText("Enter the number of columns to apply to the tab");
inputDialog.getEditor().setTextFormatter(new TextFormatter<Integer>(new IntegerStringConverter()));
inputDialog.getEditor().setText("0");
inputDialog.setHeaderText(null);
inputDialog.setTitle("New Tab Columns");
inputDialog.showAndWait()
.filter(response -> !"".equals(response))
.ifPresent( response -> this.finishNewTabDialogs(rows, Integer.parseInt(response), name));
}
示例13: handleEditMatrix
import javafx.scene.control.TextInputDialog; //导入方法依赖的package包/类
/**
* Method is called when the "Edit" button is pressed. If a valid matrix is selected in the table
* on the left, then it is deleted from the matrixTable.
*/
@FXML
private void handleEditMatrix() {
int selectedIndex = matrixTable.getSelectionModel().getSelectedIndex();
if (selectedIndex >= 0) {
// User has selected a valid matrix on the left.
TextInputDialog dialog =
new TextInputDialog(matrixTable.getSelectionModel().getSelectedItem().getName());
dialog.setTitle("Editing Matrix");
dialog.setHeaderText("Leave blank, or click cancel for no changes.");
dialog.setContentText("Please enter new name:");
Optional<String> result = dialog.showAndWait();
result.ifPresent(name -> matrixTable.getSelectionModel().getSelectedItem().setName(name));
updateMatrixList();
} else {
// Nothing is selected
MatrixAlerts.noSelectionAlert();
}
}
示例14: openBamUrl
import javafx.scene.control.TextInputDialog; //导入方法依赖的package包/类
void openBamUrl(final Window owner)
{
final String lastkey="last.bam.url";
final TextInputDialog dialog=new TextInputDialog(this.preferences.get(lastkey, ""));
dialog.setContentText("URL:");
dialog.setTitle("Get BAM URL");
dialog.setHeaderText("Input BAM URL");
final Optional<String> choice=dialog.showAndWait();
if(!choice.isPresent()) return;
BamFile input=null;
try {
input = BamFile.newInstance(choice.get());
this.preferences.put(lastkey, choice.get());
final BamStage stage=new BamStage(JfxNgs.this, input);
stage.show();
} catch (final Exception err) {
CloserUtil.close(input);
showExceptionDialog(owner, err);
}
}
示例15: openVcfUrl
import javafx.scene.control.TextInputDialog; //导入方法依赖的package包/类
void openVcfUrl(final Window owner)
{
final String lastkey="last.vcf.url";
final TextInputDialog dialog=new TextInputDialog(this.preferences.get(lastkey, ""));
dialog.setContentText("URL:");
dialog.setTitle("Get VCF URL");
dialog.setHeaderText("Input VCF URL");
final Optional<String> choice=dialog.showAndWait();
if(!choice.isPresent()) return;
VcfFile input=null;
try {
input = VcfFile.newInstance(choice.get());
this.preferences.put(lastkey, choice.get());
VcfStage stage=new VcfStage(JfxNgs.this, input);
stage.show();
} catch (final Exception err) {
CloserUtil.close(input);
showExceptionDialog(owner, err);
}
}