{"id":16884,"date":"2022-10-22T11:16:07","date_gmt":"2022-10-22T05:46:07","guid":{"rendered":"https:\/\/jassweb.com\/solved\/solved-how-to-redirect-system-input-to-javafx-textfield\/"},"modified":"2022-10-22T11:16:07","modified_gmt":"2022-10-22T05:46:07","slug":"solved-how-to-redirect-system-input-to-javafx-textfield","status":"publish","type":"post","link":"https:\/\/jassweb.com\/solved\/solved-how-to-redirect-system-input-to-javafx-textfield\/","title":{"rendered":"[Solved] how to redirect system input to javaFX textfield?"},"content":{"rendered":"<p> [ad_1]<br \/>\n<\/p>\n<div id=\"answer-73981973\" class=\"answer js-answer accepted-answer js-accepted-answer\" data-answerid=\"73981973\" data-parentid=\"73977336\" data-score=\"2\" data-position-on-page=\"1\" data-highest-scored=\"1\" data-question-has-accepted-highest-score=\"1\" itemprop=\"acceptedAnswer\" itemscope itemtype=\"https:\/\/schema.org\/Answer\">\n<div class=\"post-layout\">\n<div class=\"votecell post-layout--left\"><\/div>\n<div class=\"answercell post-layout--right\">\n<div class=\"s-prose js-post-body\" itemprop=\"text\">\n<p><em><strong>Preface:<\/strong> Given your &#8220;console application&#8221; doesn&#8217;t involve forking any processes or performing any &#8220;actual&#8221; I\/O, you may want to redesign your application to use the <code>TextField<\/code> and <code>TextArea<\/code> directly, or at least more directly than you&#8217;re currently trying to do. Using <code>System.out<\/code> and <code>System.in<\/code> adds a layer of unnecessary indirection and makes everything more complex. Also, redirecting standard out and standard in affects the whole process, which may not be desirable.<\/em><\/p>\n<hr>\n<h1>General Idea<\/h1>\n<p>Reading characters from standard in and writing characters to standard out will involve decoding and encoding those characters. You&#8217;ll want to use classes which already implement this for you, such as <code>BufferedReader<\/code> and <code>BufferedWriter<\/code>. And since you essentially want to communicate between threads via streams, you can have the underlying streams be instances of <code>PipedInputStream<\/code> and <code>PipedOutputStream<\/code>.<\/p>\n<p>Also, since most console-based applications can print prompting text without a new line at the end, you have to &#8220;read from&#8221; standard out by reading each individual character rather than line-by-line. This could involve a lot of calls to <code>Platform#runLater(Runnable)<\/code>, potentially overwhelming the FX thread, which means you should probably buffer this output.<\/p>\n<p>The example below shows a <em>proof-of-concept<\/em> for this. It uses UTF-8 for the character encoding. There&#8217;s a GIF of the example code running at the end of this answer.<\/p>\n<p>Here&#8217;s a brief overview of the classes:<\/p>\n<div class=\"s-table-container\">\n<table class=\"s-table\">\n<thead>\n<tr>\n<th>Class<\/th>\n<th>Description<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>Main<\/code><\/td>\n<td>The JavaFX application class. Creates the UI and otherwise initializes and starts the application.<\/td>\n<\/tr>\n<tr>\n<td><code>StreamWriter<\/code><\/td>\n<td>Responsible for writing the user&#8217;s input so that it can later be read by <code>System.in<\/code>. Also provides the code for redirecting <code>System.in<\/code> so that ultimately the input can come from a <code>TextField<\/code>.<\/td>\n<\/tr>\n<tr>\n<td><code>StreamReader<\/code><\/td>\n<td>Responsible for reading the output from <code>System.out<\/code> character-by-character. Also provides the code for redirecting <code>System.out<\/code> so that ultimately it can be appended to a <code>TextArea<\/code>.<\/td>\n<\/tr>\n<tr>\n<td><code>BufferedTextAreaAppender<\/code><\/td>\n<td>Responsible for taking the stream of characters from <code>StreamReader<\/code> and appending them to the <code>TextArea<\/code> in batches.<\/td>\n<\/tr>\n<tr>\n<td><code>ConsoleTask<\/code><\/td>\n<td>The &#8220;console application&#8221;. Uses <code>System.in<\/code> and <code>System.out<\/code> to interact with the user.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<hr>\n<h1>Example<\/h1>\n<p>Note that I have the <code>TextArea<\/code> set up to automatically scroll to the end when the text changes. Unfortunately, this doesn&#8217;t seem to work the first time text goes &#8220;off the screen&#8221;. But after that first time it seems to work.<\/p>\n<p><strong>Main.java<\/strong><\/p>\n<pre class=\"lang-java prettyprint-override\"><code>import java.io.IOException;\nimport java.util.concurrent.ExecutorService;\nimport java.util.concurrent.Executors;\nimport javafx.application.Application;\nimport javafx.application.Platform;\nimport javafx.geometry.Insets;\nimport javafx.scene.Scene;\nimport javafx.scene.control.TextArea;\nimport javafx.scene.control.TextField;\nimport javafx.scene.layout.Priority;\nimport javafx.scene.layout.VBox;\nimport javafx.scene.text.Font;\nimport javafx.stage.Stage;\n\npublic class Main extends Application {\n\n    private final ExecutorService threadPool = Executors.newFixedThreadPool(3, r -&gt; {\n        var t = new Thread(r);\n        t.setDaemon(true);\n        return t;\n    });\n\n    @Override\n    public void start(Stage primaryStage) throws Exception {\n        var textField = new TextField();\n        textField.setFont(Font.font(\"Monospaced\", 13));\n\n        var textArea = new TextArea();\n        textArea.setFont(textField.getFont());\n        textArea.setEditable(false);\n        textArea.setFocusTraversable(false);\n        textArea.textProperty().addListener(obs -&gt; textArea.end());\n\n        var root = new VBox(10, textArea, textField);\n        root.setPadding(new Insets(10));\n        VBox.setVgrow(textArea, Priority.ALWAYS);\n\n        primaryStage.setScene(new Scene(root, 600, 400));\n        textField.requestFocus();\n\n        primaryStage.setTitle(\"Console App\");\n        primaryStage.show();\n\n        wireInputAndOutput(textField, textArea);\n        startConsoleTask();\n    }\n\n    private void wireInputAndOutput(TextField input, TextArea output) throws IOException {\n        var inputConsumer = StreamWriter.redirectStandardIn(threadPool);\n        StreamReader.redirectStandardOut(new BufferedTextAreaAppender(output), threadPool);\n\n        input.setOnAction(e -&gt; {\n            e.consume();\n            var text = input.textProperty().getValueSafe() + \"\\n\";\n            output.appendText(text);\n            inputConsumer.accept(text);\n            input.clear();\n        });\n    }\n\n    private void startConsoleTask() {\n        threadPool.execute(new ConsoleTask(Platform::exit));\n    }\n\n    @Override\n    public void stop() {\n        threadPool.shutdownNow();\n    }\n}\n<\/code><\/pre>\n<p><strong>BufferedTextAreaAppender.java<\/strong><\/p>\n<pre class=\"lang-java prettyprint-override\"><code>import java.util.function.IntConsumer;\nimport javafx.application.Platform;\nimport javafx.scene.control.TextArea;\n\nclass BufferedTextAreaAppender implements IntConsumer {\n\n    private final StringBuilder buffer = new StringBuilder();\n    private final TextArea textArea;\n    private boolean runLater = true;\n\n    BufferedTextAreaAppender(TextArea textArea) {\n        this.textArea = textArea;\n    }\n\n    @Override\n    public void accept(int characterCodePoint) {\n        synchronized (buffer) {\n            buffer.append((char) characterCodePoint);\n            if (runLater) {\n                runLater = false;\n                Platform.runLater(this::appendToTextArea);\n            }\n        }\n    }\n\n    private void appendToTextArea() {\n        synchronized (buffer) {\n            textArea.appendText(buffer.toString());\n            buffer.delete(0, buffer.length());\n            runLater = true;\n        }\n    }\n}\n<\/code><\/pre>\n<p><strong>StreamReader.java<\/strong> (could probably use a better name)<\/p>\n<pre class=\"lang-java prettyprint-override\"><code>import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.InputStreamReader;\nimport java.io.InterruptedIOException;\nimport java.io.PipedInputStream;\nimport java.io.PipedOutputStream;\nimport java.io.PrintStream;\nimport java.io.UncheckedIOException;\nimport java.nio.charset.StandardCharsets;\nimport java.util.concurrent.Executor;\nimport java.util.function.IntConsumer;\n\nclass StreamReader implements Runnable {\n\n    static void redirectStandardOut(IntConsumer onNextCharacter, Executor executor) throws IOException {\n        var out = new PipedOutputStream();\n        System.setOut(new PrintStream(out, true, StandardCharsets.UTF_8));\n\n        var reader = new StreamReader(new PipedInputStream(out), onNextCharacter);\n        executor.execute(reader);\n    }\n\n    private final BufferedReader reader;\n    private final IntConsumer onNextCharacter;\n\n    StreamReader(InputStream stream, IntConsumer onNextCharacter) {\n        this.reader = new BufferedReader(new InputStreamReader(stream, StandardCharsets.UTF_8));\n        this.onNextCharacter = onNextCharacter;\n    }\n\n    @Override\n    public void run() {\n        try (reader) {\n            int charAsInt;\n            while (!Thread.interrupted() &amp;&amp; (charAsInt = reader.read()) != -1) {\n                onNextCharacter.accept(charAsInt);\n            }\n        } catch (InterruptedIOException ignore) {\n        } catch (IOException ioe) {\n            throw new UncheckedIOException(ioe);\n        }\n    }\n}\n<\/code><\/pre>\n<p><strong>StreamWriter.java<\/strong> (could probably use a better name)<\/p>\n<pre class=\"lang-java prettyprint-override\"><code>import java.io.BufferedWriter;\nimport java.io.IOException;\nimport java.io.InterruptedIOException;\nimport java.io.OutputStream;\nimport java.io.OutputStreamWriter;\nimport java.io.PipedInputStream;\nimport java.io.PipedOutputStream;\nimport java.io.UncheckedIOException;\nimport java.nio.charset.StandardCharsets;\nimport java.util.concurrent.ArrayBlockingQueue;\nimport java.util.concurrent.BlockingQueue;\nimport java.util.concurrent.Executor;\nimport java.util.function.Consumer;\n\nclass StreamWriter implements Runnable {\n\n    static Consumer&lt;CharSequence&gt; redirectStandardIn(Executor executor) throws IOException {\n        var in = new PipedInputStream();\n        System.setIn(in);\n\n        var queue = new ArrayBlockingQueue&lt;CharSequence&gt;(500);\n        var writer = new StreamWriter(new PipedOutputStream(in), queue);\n        executor.execute(writer);\n\n        return queue::add;\n    }\n\n    private final BufferedWriter writer;\n    private final BlockingQueue&lt;? extends CharSequence&gt; lineQueue;\n\n    StreamWriter(OutputStream out, BlockingQueue&lt;? extends CharSequence&gt; lineQueue) {\n        this.writer = new BufferedWriter(new OutputStreamWriter(out, StandardCharsets.UTF_8));\n        this.lineQueue = lineQueue;\n    }\n\n    @Override\n    public void run() {\n        try (writer) {\n            while (!Thread.interrupted()) {\n                writer.append(lineQueue.take());\n                writer.flush();\n            }\n        } catch (InterruptedIOException | InterruptedException ignore) {\n        } catch (IOException ioe) {\n            throw new UncheckedIOException(ioe);\n        }\n    }\n}\n<\/code><\/pre>\n<p><strong>ConsoleTask.java<\/strong><\/p>\n<pre class=\"lang-java prettyprint-override\"><code>import java.nio.charset.StandardCharsets;\nimport java.util.NoSuchElementException;\nimport java.util.Scanner;\n\nclass ConsoleTask implements Runnable {\n\n    private final Scanner scanner = new Scanner(System.in);\n    private final Runnable onExit;\n\n    ConsoleTask(Runnable onExit) {\n        this.onExit = onExit;\n    }\n\n    @Override\n    public void run() {\n        System.out.println(\"WELCOME TO CONSOLE APP!\");\n\n        boolean running = true;\n        while (running &amp;&amp; !Thread.interrupted()) {\n            printOptions();\n\n            int choice = readInt(\"Choose option: \", 1, 3);\n            switch (choice) {\n                case 1 -&gt; doCheckIfLeapYear();\n                case 2 -&gt; doCheckIfPrime();\n                case 3 -&gt; running = false;\n                default -&gt; System.out.println(\"Unknown option!\");\n            }\n        }\n\n        onExit.run();\n    }\n\n    private void printOptions() {\n        System.out.println();\n        System.out.println(\"Options\");\n        System.out.println(\"-------\");\n        System.out.println(\"  1) Test Leap Year\");\n        System.out.println(\"  2) Test Prime\");\n        System.out.println(\"  3) Exit\");\n        System.out.println();\n    }\n\n    private int readInt(String prompt, int min, int max) {\n        while (true) {\n            System.out.print(prompt);\n\n            try {\n                int i = Integer.parseInt(scanner.nextLine());\n                if (i &gt;= min &amp;&amp; i &lt;= max) {\n                    return i;\n                }\n            } catch (NumberFormatException | NoSuchElementException ignored) {\n            }\n            System.out.printf(\"Please enter an integer between [%,d, %,d]%n\", min, max);\n        }\n    }\n\n    private void doCheckIfLeapYear() {\n        System.out.println();\n        int year = readInt(\"Enter year: \", 0, 1_000_000);\n        if (year % 4 == 0 || (year % 100 == 0 &amp;&amp; year % 400 != 0)) {\n            System.out.printf(\"The year %d is a leap year.%n\", year);\n        } else {\n            System.out.printf(\"The year %d is NOT a leap year.%n\", year);\n        }\n    }\n\n    private void doCheckIfPrime() {\n        System.out.println();\n        int number = readInt(\"Enter an integer: \", 1, Integer.MAX_VALUE);\n\n        boolean isPrime = true;\n        for (int i = 2; i &lt;= (int) Math.sqrt(number); i++) {\n            if (number % i == 0) {\n                isPrime = false;\n                break;\n            }\n        }\n\n        if (isPrime) {\n            System.out.printf(\"The number %,d is prime.%n\", number);\n        } else {\n            System.out.printf(\"The number %,d is NOT prime.%n\", number);\n        }\n    }\n}\n<\/code><\/pre>\n<h2>GIF of Example<\/h2>\n<p><a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/jassweb.com\/solved\/wp-content\/uploads\/2022\/10\/Solved-how-to-redirect-system-input-to-javaFX-textfield.gif\"><img decoding=\"async\" src=\"https:\/\/jassweb.com\/solved\/wp-content\/uploads\/2022\/10\/Solved-how-to-redirect-system-input-to-javaFX-textfield.gif\" alt=\"GIF image of example code running\"><\/a><\/p>\n<\/p><\/div>\n<div class=\"mt24\"><\/div>\n<\/div>\n<p>            <span class=\"d-none\" itemprop=\"commentCount\">10<\/span> <\/p><\/div>\n<\/div>\n<p>[ad_2]<\/p>\n<p>solved how to redirect system input to javaFX textfield? <\/p>\n","protected":false},"excerpt":{"rendered":"<p>[ad_1] Preface: Given your &#8220;console application&#8221; doesn&#8217;t involve forking any processes or performing any &#8220;actual&#8221; I\/O, you may want to redesign your application to use the TextField and TextArea directly, or at least more directly than you&#8217;re currently trying to do. Using System.out and System.in adds a layer of unnecessary indirection and makes everything more &#8230; <a title=\"[Solved] how to redirect system input to javaFX textfield?\" class=\"read-more\" href=\"https:\/\/jassweb.com\/solved\/solved-how-to-redirect-system-input-to-javafx-textfield\/\" aria-label=\"More on [Solved] how to redirect system input to javaFX textfield?\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[320],"tags":[323,1489],"class_list":["post-16884","post","type-post","status-publish","format-standard","hentry","category-solved","tag-java","tag-javafx"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>[Solved] how to redirect system input to javaFX textfield? - JassWeb<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/jassweb.com\/solved\/solved-how-to-redirect-system-input-to-javafx-textfield\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"[Solved] how to redirect system input to javaFX textfield? - JassWeb\" \/>\n<meta property=\"og:description\" content=\"[ad_1] Preface: Given your &#8220;console application&#8221; doesn&#8217;t involve forking any processes or performing any &#8220;actual&#8221; I\/O, you may want to redesign your application to use the TextField and TextArea directly, or at least more directly than you&#8217;re currently trying to do. Using System.out and System.in adds a layer of unnecessary indirection and makes everything more ... Read more\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jassweb.com\/solved\/solved-how-to-redirect-system-input-to-javafx-textfield\/\" \/>\n<meta property=\"og:site_name\" content=\"JassWeb\" \/>\n<meta property=\"article:published_time\" content=\"2022-10-22T05:46:07+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/jassweb.com\/solved\/wp-content\/uploads\/2022\/10\/Solved-how-to-redirect-system-input-to-javaFX-textfield.gif\" \/>\n<meta name=\"author\" content=\"Kirat\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Kirat\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/jassweb.com\/solved\/solved-how-to-redirect-system-input-to-javafx-textfield\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/jassweb.com\/solved\/solved-how-to-redirect-system-input-to-javafx-textfield\/\"},\"author\":{\"name\":\"Kirat\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31\"},\"headline\":\"[Solved] how to redirect system input to javaFX textfield?\",\"datePublished\":\"2022-10-22T05:46:07+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/jassweb.com\/solved\/solved-how-to-redirect-system-input-to-javafx-textfield\/\"},\"wordCount\":396,\"publisher\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#organization\"},\"image\":{\"@id\":\"https:\/\/jassweb.com\/solved\/solved-how-to-redirect-system-input-to-javafx-textfield\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/jassweb.com\/solved\/wp-content\/uploads\/2022\/10\/Solved-how-to-redirect-system-input-to-javaFX-textfield.gif\",\"keywords\":[\"java\",\"javafx\"],\"articleSection\":[\"Solved\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/jassweb.com\/solved\/solved-how-to-redirect-system-input-to-javafx-textfield\/\",\"url\":\"https:\/\/jassweb.com\/solved\/solved-how-to-redirect-system-input-to-javafx-textfield\/\",\"name\":\"[Solved] how to redirect system input to javaFX textfield? - JassWeb\",\"isPartOf\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/jassweb.com\/solved\/solved-how-to-redirect-system-input-to-javafx-textfield\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/jassweb.com\/solved\/solved-how-to-redirect-system-input-to-javafx-textfield\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/jassweb.com\/solved\/wp-content\/uploads\/2022\/10\/Solved-how-to-redirect-system-input-to-javaFX-textfield.gif\",\"datePublished\":\"2022-10-22T05:46:07+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/jassweb.com\/solved\/solved-how-to-redirect-system-input-to-javafx-textfield\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/jassweb.com\/solved\/solved-how-to-redirect-system-input-to-javafx-textfield\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/jassweb.com\/solved\/solved-how-to-redirect-system-input-to-javafx-textfield\/#primaryimage\",\"url\":\"https:\/\/jassweb.com\/solved\/wp-content\/uploads\/2022\/10\/Solved-how-to-redirect-system-input-to-javaFX-textfield.gif\",\"contentUrl\":\"https:\/\/jassweb.com\/solved\/wp-content\/uploads\/2022\/10\/Solved-how-to-redirect-system-input-to-javaFX-textfield.gif\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/jassweb.com\/solved\/solved-how-to-redirect-system-input-to-javafx-textfield\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/jassweb.com\/solved\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"[Solved] how to redirect system input to javaFX textfield?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/jassweb.com\/solved\/#website\",\"url\":\"https:\/\/jassweb.com\/solved\/\",\"name\":\"JassWeb\",\"description\":\"Build High-quality Websites\",\"publisher\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/jassweb.com\/solved\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/jassweb.com\/solved\/#organization\",\"name\":\"Jass Web\",\"url\":\"https:\/\/jassweb.com\/solved\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png\",\"contentUrl\":\"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png\",\"width\":693,\"height\":132,\"caption\":\"Jass Web\"},\"image\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31\",\"name\":\"Kirat\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1776403586\",\"contentUrl\":\"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1776403586\",\"caption\":\"Kirat\"},\"sameAs\":[\"http:\/\/jassweb.com\"],\"url\":\"https:\/\/jassweb.com\/solved\/author\/jaspritsinghghumangmail-com\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"[Solved] how to redirect system input to javaFX textfield? - JassWeb","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/jassweb.com\/solved\/solved-how-to-redirect-system-input-to-javafx-textfield\/","og_locale":"en_US","og_type":"article","og_title":"[Solved] how to redirect system input to javaFX textfield? - JassWeb","og_description":"[ad_1] Preface: Given your &#8220;console application&#8221; doesn&#8217;t involve forking any processes or performing any &#8220;actual&#8221; I\/O, you may want to redesign your application to use the TextField and TextArea directly, or at least more directly than you&#8217;re currently trying to do. Using System.out and System.in adds a layer of unnecessary indirection and makes everything more ... Read more","og_url":"https:\/\/jassweb.com\/solved\/solved-how-to-redirect-system-input-to-javafx-textfield\/","og_site_name":"JassWeb","article_published_time":"2022-10-22T05:46:07+00:00","og_image":[{"url":"https:\/\/jassweb.com\/solved\/wp-content\/uploads\/2022\/10\/Solved-how-to-redirect-system-input-to-javaFX-textfield.gif","type":"","width":"","height":""}],"author":"Kirat","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Kirat","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jassweb.com\/solved\/solved-how-to-redirect-system-input-to-javafx-textfield\/#article","isPartOf":{"@id":"https:\/\/jassweb.com\/solved\/solved-how-to-redirect-system-input-to-javafx-textfield\/"},"author":{"name":"Kirat","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31"},"headline":"[Solved] how to redirect system input to javaFX textfield?","datePublished":"2022-10-22T05:46:07+00:00","mainEntityOfPage":{"@id":"https:\/\/jassweb.com\/solved\/solved-how-to-redirect-system-input-to-javafx-textfield\/"},"wordCount":396,"publisher":{"@id":"https:\/\/jassweb.com\/solved\/#organization"},"image":{"@id":"https:\/\/jassweb.com\/solved\/solved-how-to-redirect-system-input-to-javafx-textfield\/#primaryimage"},"thumbnailUrl":"https:\/\/jassweb.com\/solved\/wp-content\/uploads\/2022\/10\/Solved-how-to-redirect-system-input-to-javaFX-textfield.gif","keywords":["java","javafx"],"articleSection":["Solved"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/jassweb.com\/solved\/solved-how-to-redirect-system-input-to-javafx-textfield\/","url":"https:\/\/jassweb.com\/solved\/solved-how-to-redirect-system-input-to-javafx-textfield\/","name":"[Solved] how to redirect system input to javaFX textfield? - JassWeb","isPartOf":{"@id":"https:\/\/jassweb.com\/solved\/#website"},"primaryImageOfPage":{"@id":"https:\/\/jassweb.com\/solved\/solved-how-to-redirect-system-input-to-javafx-textfield\/#primaryimage"},"image":{"@id":"https:\/\/jassweb.com\/solved\/solved-how-to-redirect-system-input-to-javafx-textfield\/#primaryimage"},"thumbnailUrl":"https:\/\/jassweb.com\/solved\/wp-content\/uploads\/2022\/10\/Solved-how-to-redirect-system-input-to-javaFX-textfield.gif","datePublished":"2022-10-22T05:46:07+00:00","breadcrumb":{"@id":"https:\/\/jassweb.com\/solved\/solved-how-to-redirect-system-input-to-javafx-textfield\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jassweb.com\/solved\/solved-how-to-redirect-system-input-to-javafx-textfield\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jassweb.com\/solved\/solved-how-to-redirect-system-input-to-javafx-textfield\/#primaryimage","url":"https:\/\/jassweb.com\/solved\/wp-content\/uploads\/2022\/10\/Solved-how-to-redirect-system-input-to-javaFX-textfield.gif","contentUrl":"https:\/\/jassweb.com\/solved\/wp-content\/uploads\/2022\/10\/Solved-how-to-redirect-system-input-to-javaFX-textfield.gif"},{"@type":"BreadcrumbList","@id":"https:\/\/jassweb.com\/solved\/solved-how-to-redirect-system-input-to-javafx-textfield\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/jassweb.com\/solved\/"},{"@type":"ListItem","position":2,"name":"[Solved] how to redirect system input to javaFX textfield?"}]},{"@type":"WebSite","@id":"https:\/\/jassweb.com\/solved\/#website","url":"https:\/\/jassweb.com\/solved\/","name":"JassWeb","description":"Build High-quality Websites","publisher":{"@id":"https:\/\/jassweb.com\/solved\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/jassweb.com\/solved\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/jassweb.com\/solved\/#organization","name":"Jass Web","url":"https:\/\/jassweb.com\/solved\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/","url":"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png","contentUrl":"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png","width":693,"height":132,"caption":"Jass Web"},"image":{"@id":"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31","name":"Kirat","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/image\/","url":"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1776403586","contentUrl":"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1776403586","caption":"Kirat"},"sameAs":["http:\/\/jassweb.com"],"url":"https:\/\/jassweb.com\/solved\/author\/jaspritsinghghumangmail-com\/"}]}},"_links":{"self":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts\/16884","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/comments?post=16884"}],"version-history":[{"count":0,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts\/16884\/revisions"}],"wp:attachment":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/media?parent=16884"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/categories?post=16884"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/tags?post=16884"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}