Is there a way to print text after the line where the user inputs?
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
add a comment |
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
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
add a comment |
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
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
java
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
add a comment |
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
add a comment |
2 Answers
2
active
oldest
votes
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.
add a comment |
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
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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.
add a comment |
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.
add a comment |
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.
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.
answered Dec 30 '18 at 4:57
Aditya GuptaAditya Gupta
7501820
7501820
add a comment |
add a comment |
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
add a comment |
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
add a comment |
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
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
answered Dec 30 '18 at 5:48
SandSand
1,6122421
1,6122421
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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