From: Mike Barnard on
Hi all.

As some of you may remember from a couple of other recent newbie
posts, I'm trying to teach myself, slowly, by book. As in previous
posts can you give me some guidance please?

Currently I want to learn about reading input from the keyboard. Doing
a google search for "Java keyboard input" and similar hasn't brought
me to the nirvana I'd like. I know it must be there, but where?

What I do get are hits such as:

http://wiki.erland.homeip.net/index.php/Java_Tutorial_Lesson_12:_Keyboard_input
which is part way through something else,

http://www.pp.rhul.ac.uk/~george/PH2150/html/node13.html
This says what, but not why,

http://www.brighthub.com/internet/web-development/articles/16220.aspx
3d on the web... and very high on the list of Google responses.

Of course, working through them I'm sure I can come to some sort of
realisation of what it entails, but I'm looking for the full
explanation.

My book, Head First Java, doesn't have "keyboard" in the index. The
only "Input" in the index is "InputStreamReader" which is used in
reference to reading data from a socket.

[An "aha!" moment] I've just found a document in the Java Tutorials
called basic i/o. This may be my nirvana but in case not I'll post
this anyway.

So, can the Fount Of All Knowledge point me to a good tutorial on the
most efficient methods to get input from a user please? I don't expect
hand holding, honestly, just pointers to really useful tutorials.

Thanks in advance.

Mike.
From: Mike Barnard on
On 18 Jul 2010 10:59:06 GMT, ram(a)zedat.fu-berlin.de (Stefan Ram)
wrote:

>Mike Barnard <m.barnard.trousers(a)thunderin.co.uk> writes:
>>So, can the Fount Of All Knowledge point me to a good tutorial on the
>>most efficient methods to get input from a user please? I don't expect
>>hand holding, honestly, just pointers to really useful tutorials.
>
> To get text from the keyboard, the most obvious means
> to me would be a javax.swing.JTextField.

I'm still on the absolute basics, and Swing is a subject still to be
touched. Thanks anyway, it's bookmarked for the future!

Mike.
From: Roedy Green on
On Sun, 18 Jul 2010 11:50:45 +0100, Mike Barnard
<m.barnard.trousers(a)thunderin.co.uk> wrote, quoted or indirectly
quoted someone who said :

>Hi all.
>
>As some of you may remember from a couple of other recent newbie
>posts, I'm trying to teach myself, slowly, by book. As in previous
>posts can you give me some guidance please?
>
>Currently I want to learn about reading input from the keyboard. Doing
>a google search for "Java keyboard input" and similar hasn't brought
>me to the nirvana I'd like. I know it must be there, but where?
>
>What I do get are hits such as:
>
>http://wiki.erland.homeip.net/index.php/Java_Tutorial_Lesson_12:_Keyboard_input
>which is part way through something else,
>
>http://www.pp.rhul.ac.uk/~george/PH2150/html/node13.html
>This says what, but not why,
>
>http://www.brighthub.com/internet/web-development/articles/16220.aspx
>3d on the web... and very high on the list of Google responses.
>
>Of course, working through them I'm sure I can come to some sort of
>realisation of what it entails, but I'm looking for the full
>explanation.
>
>My book, Head First Java, doesn't have "keyboard" in the index. The
>only "Input" in the index is "InputStreamReader" which is used in
>reference to reading data from a socket.
>
>[An "aha!" moment] I've just found a document in the Java Tutorials
>called basic i/o. This may be my nirvana but in case not I'll post
>this anyway.
>
>So, can the Fount Of All Knowledge point me to a good tutorial on the
>most efficient methods to get input from a user please? I don't expect
>hand holding, honestly, just pointers to really useful tutorials.
>
>Thanks in advance.
>
>Mike.

see http://mindprod.com/products1.html#KEYPLAYER
for how to read the keyboard at a low level.

Normally you do it with components such as JTextField and brethren.
See http://mindprod.com/jgloss/jtextfield.html
--
Roedy Green Canadian Mind Products
http://mindprod.com

You encapsulate not just to save typing, but more importantly, to make it easy and safe to change the code later, since you then need change the logic in only one place. Without it, you might fail to change the logic in all the places it occurs.
From: Jussi Piitulainen on
Mike Barnard writes:

> Hi all.
>
> As some of you may remember from a couple of other recent newbie
> posts, I'm trying to teach myself, slowly, by book. As in previous
> posts can you give me some guidance please?
>
> Currently I want to learn about reading input from the keyboard. Doing
> a google search for "Java keyboard input" and similar hasn't brought
> me to the nirvana I'd like. I know it must be there, but where?

You might find something relevant with "java readline" or "java
editline" or "java jline". These lead to a couple of libraries that
provide an editable command line, including history.

I used one of these a few years ago - jline, I think - on some
GNU/Linux system.
From: Mike Barnard on
On Sun, 18 Jul 2010 11:50:45 +0100, Mike Barnard
<m.barnard.trousers(a)thunderin.co.uk> wrote:

>Hi all.
>

Another lazy sunday afternoon post. My thanks to one and all. At the
moment I am learning via the command line and have done no work with a
GUI. I'm looking for stuff like Basic's "Input" command or Delphi's
"OnKeyPress" maybe.

I have a simple, single class which I'm using to play with creating
objects, for my education. I want a method that gets a keypress from
the user (Just a single character) and will allow me to do stuff
depending on what it is.

Console isn't in the Head First book either, but searching the web for
that brings up a different list of options, so I'll play on.

Thanks again.