Is there a way to print text after the line where the user inputs?












3















I'm looking to print text on a line that is AFTER where the user is inputing their text.



String userInput;

System.out.println("Hello");
userInput = In.getString();
//I want a System.out.print(""); right here, but I want it to appear while
//the user is still typing their input.


Print: "Hello"



User is getting input



Print "I am printing this at the same time that the user is typing"










share|improve this question























  • Main thread cannot do concurrency execution, you need two threads that run concurrently to do this

    – Deadpool
    Dec 30 '18 at 4:14






  • 3





    Write a Java Swing GUI application. Create a text field. Write a Key listener to intercept keystrokes typed into the text field. Create a second text field. For every key detected by the listener, echo the corresponding character into the second text field. Easy Peasy ;) Doing something in line-oriented text mode in Java, without curses: not so much...

    – paulsm4
    Dec 30 '18 at 4:15


















3















I'm looking to print text on a line that is AFTER where the user is inputing their text.



String userInput;

System.out.println("Hello");
userInput = In.getString();
//I want a System.out.print(""); right here, but I want it to appear while
//the user is still typing their input.


Print: "Hello"



User is getting input



Print "I am printing this at the same time that the user is typing"










share|improve this question























  • Main thread cannot do concurrency execution, you need two threads that run concurrently to do this

    – Deadpool
    Dec 30 '18 at 4:14






  • 3





    Write a Java Swing GUI application. Create a text field. Write a Key listener to intercept keystrokes typed into the text field. Create a second text field. For every key detected by the listener, echo the corresponding character into the second text field. Easy Peasy ;) Doing something in line-oriented text mode in Java, without curses: not so much...

    – paulsm4
    Dec 30 '18 at 4:15
















3












3








3








I'm looking to print text on a line that is AFTER where the user is inputing their text.



String userInput;

System.out.println("Hello");
userInput = In.getString();
//I want a System.out.print(""); right here, but I want it to appear while
//the user is still typing their input.


Print: "Hello"



User is getting input



Print "I am printing this at the same time that the user is typing"










share|improve this question














I'm looking to print text on a line that is AFTER where the user is inputing their text.



String userInput;

System.out.println("Hello");
userInput = In.getString();
//I want a System.out.print(""); right here, but I want it to appear while
//the user is still typing their input.


Print: "Hello"



User is getting input



Print "I am printing this at the same time that the user is typing"







java






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Dec 30 '18 at 4:10









Sammy12333Sammy12333

161




161













  • Main thread cannot do concurrency execution, you need two threads that run concurrently to do this

    – Deadpool
    Dec 30 '18 at 4:14






  • 3





    Write a Java Swing GUI application. Create a text field. Write a Key listener to intercept keystrokes typed into the text field. Create a second text field. For every key detected by the listener, echo the corresponding character into the second text field. Easy Peasy ;) Doing something in line-oriented text mode in Java, without curses: not so much...

    – paulsm4
    Dec 30 '18 at 4:15





















  • Main thread cannot do concurrency execution, you need two threads that run concurrently to do this

    – Deadpool
    Dec 30 '18 at 4:14






  • 3





    Write a Java Swing GUI application. Create a text field. Write a Key listener to intercept keystrokes typed into the text field. Create a second text field. For every key detected by the listener, echo the corresponding character into the second text field. Easy Peasy ;) Doing something in line-oriented text mode in Java, without curses: not so much...

    – paulsm4
    Dec 30 '18 at 4:15



















Main thread cannot do concurrency execution, you need two threads that run concurrently to do this

– Deadpool
Dec 30 '18 at 4:14





Main thread cannot do concurrency execution, you need two threads that run concurrently to do this

– Deadpool
Dec 30 '18 at 4:14




3




3





Write a Java Swing GUI application. Create a text field. Write a Key listener to intercept keystrokes typed into the text field. Create a second text field. For every key detected by the listener, echo the corresponding character into the second text field. Easy Peasy ;) Doing something in line-oriented text mode in Java, without curses: not so much...

– paulsm4
Dec 30 '18 at 4:15







Write a Java Swing GUI application. Create a text field. Write a Key listener to intercept keystrokes typed into the text field. Create a second text field. For every key detected by the listener, echo the corresponding character into the second text field. Easy Peasy ;) Doing something in line-oriented text mode in Java, without curses: not so much...

– paulsm4
Dec 30 '18 at 4:15














2 Answers
2






active

oldest

votes


















1














As mentioned in the comments, keystrokes cannot be captured in raw java console applications.



His could be do e using gui applications like using AWT/Swing GUI.



Since this could be an overkill for your problem, you should know that java suports editing of console outputs in a way.



E.g. if the current output has hello, printing b character will erase one character from console and it will look like hell.



Perhaps you can think in these lines and build your functionality.






share|improve this answer































    0














    You can put console into raw mode. There is no built-in platform-independent way of getting there. This might be a solution you can implement,



    Non blocking console input in Python and Java



    got it from here. There are more solutions in there that might be helpful






    share|improve this answer























      Your Answer






      StackExchange.ifUsing("editor", function () {
      StackExchange.using("externalEditor", function () {
      StackExchange.using("snippets", function () {
      StackExchange.snippets.init();
      });
      });
      }, "code-snippets");

      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "1"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53975217%2fis-there-a-way-to-print-text-after-the-line-where-the-user-inputs%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      1














      As mentioned in the comments, keystrokes cannot be captured in raw java console applications.



      His could be do e using gui applications like using AWT/Swing GUI.



      Since this could be an overkill for your problem, you should know that java suports editing of console outputs in a way.



      E.g. if the current output has hello, printing b character will erase one character from console and it will look like hell.



      Perhaps you can think in these lines and build your functionality.






      share|improve this answer




























        1














        As mentioned in the comments, keystrokes cannot be captured in raw java console applications.



        His could be do e using gui applications like using AWT/Swing GUI.



        Since this could be an overkill for your problem, you should know that java suports editing of console outputs in a way.



        E.g. if the current output has hello, printing b character will erase one character from console and it will look like hell.



        Perhaps you can think in these lines and build your functionality.






        share|improve this answer


























          1












          1








          1







          As mentioned in the comments, keystrokes cannot be captured in raw java console applications.



          His could be do e using gui applications like using AWT/Swing GUI.



          Since this could be an overkill for your problem, you should know that java suports editing of console outputs in a way.



          E.g. if the current output has hello, printing b character will erase one character from console and it will look like hell.



          Perhaps you can think in these lines and build your functionality.






          share|improve this answer













          As mentioned in the comments, keystrokes cannot be captured in raw java console applications.



          His could be do e using gui applications like using AWT/Swing GUI.



          Since this could be an overkill for your problem, you should know that java suports editing of console outputs in a way.



          E.g. if the current output has hello, printing b character will erase one character from console and it will look like hell.



          Perhaps you can think in these lines and build your functionality.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Dec 30 '18 at 4:57









          Aditya GuptaAditya Gupta

          7501820




          7501820

























              0














              You can put console into raw mode. There is no built-in platform-independent way of getting there. This might be a solution you can implement,



              Non blocking console input in Python and Java



              got it from here. There are more solutions in there that might be helpful






              share|improve this answer




























                0














                You can put console into raw mode. There is no built-in platform-independent way of getting there. This might be a solution you can implement,



                Non blocking console input in Python and Java



                got it from here. There are more solutions in there that might be helpful






                share|improve this answer


























                  0












                  0








                  0







                  You can put console into raw mode. There is no built-in platform-independent way of getting there. This might be a solution you can implement,



                  Non blocking console input in Python and Java



                  got it from here. There are more solutions in there that might be helpful






                  share|improve this answer













                  You can put console into raw mode. There is no built-in platform-independent way of getting there. This might be a solution you can implement,



                  Non blocking console input in Python and Java



                  got it from here. There are more solutions in there that might be helpful







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Dec 30 '18 at 5:48









                  SandSand

                  1,6122421




                  1,6122421






























                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53975217%2fis-there-a-way-to-print-text-after-the-line-where-the-user-inputs%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Mossoró

                      Error while reading .h5 file using the rhdf5 package in R

                      Pushsharp Apns notification error: 'InvalidToken'