java - How do I clear the input field of a TextInputDialog? -


my javafx program has series of prompts asking user information. rather create new textinputdialog each prompt, want create single textinputdialog , reuse multiple prompts.

import java.util.optional; import javafx.application.application; import javafx.scene.control.textinputdialog; import javafx.stage.stage;  public class inventorylist extends application {     public static void main(string[] args) {         launch(args);     }      @override     public void start(stage primarystage) {         optional<string> name;         optional<string> price;          // fetch user input         textinputdialog textdialog = new textinputdialog();         textdialog.settitle("create new item");         textdialog.setheadertext(null);          textdialog.setcontenttext("enter item name:");         name = textdialog.showandwait();          textdialog.setcontenttext("enter item price:");         price = textdialog.showandwait();     } } 

unfortunately, user's typed input first prompt...

first prompt

isn't cleared when starting second prompt.

second prompt.

is possible clear textfield between prompts?

textdialog.geteditor().clear(); 

Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -