Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / May 2007

Tip: Looking for answers? Try searching our database.

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

Thread view: 
John - 24 Apr 2007 02:24 GMT
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 - 24 Apr 2007 03:59 GMT
..
>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>

Signature

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

John  Hartnup - 24 Apr 2007 09:03 GMT
> .
>
> >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 - 24 Apr 2007 13:54 GMT
>> .
>>
[quoted text clipped - 16 lines]
> What are you using to collect input? System.in.read()? The
> aforementioned screen handling library?
John - 24 Apr 2007 13:58 GMT
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

>> .
>>
[quoted text clipped - 16 lines]
> What are you using to collect input? System.in.read()? The
> aforementioned screen handling library?
Martin Gerner - 25 May 2007 15:06 GMT
> 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.

Signature

Martin Gerner



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.