How to control the cursor positon of java program in console mode?

J

John

I am writing a small database that requires user input.

However, whenever something is output to the screen, the cursor stays at the
beginning of the output instead of the end of the output.

How can I let it go to the end of the output?

For example:

say, the output is like this:

This is a database. Please input your information below.
prompt:>

I want the cursor to go to after the ">" sign but it stays in front of
"this" although whenever the user presses the keyboard it goes the end after
">".

This is not a big problem but makes my application look not so professional.

Anyway to cure this?

John
 
A

Andrew Thompson

John wrote:
..
This is not a big problem but makes my application look not so professional.

Nothing in a console has 'looked professional' for
around the last 2 decades.
Anyway to cure this?

GUI e.g.

<sscce>
import javax.swing.JOptionPane;

class DataBaseFrontEnd {

public static void main(String[] args) {
JOptionPane.showMessageDialog(null,
"<html><body><center>Welcome to the " +
"<br><em>XYZ DataBase Application</em>");
String response = JOptionPane.showInputDialog(null,
"Please enter your information ");
JOptionPane.showMessageDialog(null,
"Sending to D/B: '" + response + "'");
}
}
</sscce>

--
Andrew Thompson
http://www.athompson.info/andrew/

Message posted via JavaKB.com
http://www.javakb.com/Uwe/Forums.aspx/java-general/200704/1
 
J

John Hartnup

John wrote:

.


Nothing in a console has 'looked professional' for
around the last 2 decades.

Don't be ridiculous. For example, no serious UNIX database would ship
without a text mode admin tool.

John, you probably need to add some more detail to your question. What
sort of output are you using? An MSDOS window? A UNIX terminal
emulator? The Eclipse console?

What are you using to output your text? System.out.println()? Some
kind of screen handling library?

What are you using to collect input? System.in.read()? The
aforementioned screen handling library?
 
J

John

John Hartnup said:
Don't be ridiculous. For example, no serious UNIX database would ship
without a text mode admin tool.

John, you probably need to add some more detail to your question. What
sort of output are you using? An MSDOS window? A UNIX terminal
emulator? The Eclipse console?

What are you using to output your text? System.out.println()? Some
kind of screen handling library?

What are you using to collect input? System.in.read()? The
aforementioned screen handling library?
 
J

John

My input is scanner.nextline();
output is System.out.print()

System.out.print() or println doesn't make much difference since I can
always add "\n" to the end of message.

The console here is Eclipse console in windows xp.
I haven't tried dos window yet.

Not a big deal. Just not so professional.

John
 
M

Martin Gerner

John said:
The console here is Eclipse console in windows xp.
I haven't tried dos window yet.

I can't say this for absolute certain, but I am quite sure that if you were
to try out your program in a "normal" console - like XP's command prompt -
it would look correct.

I quickly checked one of my own programs - which also uses
System.out.println and Scanner.nextLine() - and the cursor behaves as it
should, both in XP's command prompt and on a linux console.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,818
Latest member
Brigette36

Latest Threads

Top