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





PostPosted: 2007-4-24 9:24:00 Top

java-programmer, How to control the cursor positon of java program in console mode? 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


 
Andrew Thompson





PostPosted: 2007-4-24 10:59:00 Top

java-programmer >> How to control the cursor positon of java program in console mode? 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

 
John Hartnup





PostPosted: 2007-4-24 16:04:00 Top

java-programmer >> How to control the cursor positon of java program in console mode? On Apr 24, 11:59 am, "Andrew Thompson" <u32984@uwe> wrote:
> 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.

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?



 
 
John





PostPosted: 2007-4-24 20:55:00 Top

java-programmer >> How to control the cursor positon of java program in console mode?
"John Hartnup" <email***@***.com> wrote in message
news:email***@***.com...
> On Apr 24, 11:59 am, "Andrew Thompson" <u32984@uwe> wrote:
>> 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.
>
> 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?
>
>
>


 
 
John





PostPosted: 2007-4-24 20:58:00 Top

java-programmer >> How to control the cursor positon of java program in console mode? 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


"John Hartnup" <email***@***.com> wrote in message
news:email***@***.com...
> On Apr 24, 11:59 am, "Andrew Thompson" <u32984@uwe> wrote:
>> 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.
>
> 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?
>
>
>


 
 
Martin Gerner





PostPosted: 2007-5-25 22:07:00 Top

java-programmer >> How to control the cursor positon of java program in console mode? "John" <email***@***.com> wrote in news:f0kut4$pni$email***@***.com:

> 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.

--
Martin Gerner