Hello everybody,
I understand the basics of Java, but not such features as are helpful in an applet namely Listeners.
I wanted to create a feature like this:
A program would be displayed in the regular old System.out.
It would be looping continuously doing something unimportant, say counting how many times it could count to a billion, until the user enters a command, and then it would simply delay what it was doing, display something unimportant ("hello") and then go back to what it was doing.
At current I only know how to make the program Stop and Wait for the user to enter something, and then do it again.
I know that a key listener or something similar is what I'm after, but I don't know how to use them or if I need one, because I only want input from System.in (which I would usually use a Scanner to get).
Could someone point me to a proper tutorial, or perhaps crack out an example for me?
All in all I'm looking for:
Something that will listen for the user to hit the Enter key, then read in whatever they typed before it in the command line, rather than some newly created and displayed text box.
Thanks everyone for your time.
5 1537
Hold on. I didnt go beyond the first line, you really need to learn the language first before doing anything.
Start here Sun Tutorials
regards,
ajos
Thanks, I used the wrong wording.
I know Java well enough to create a text only spreadsheet application displayed in the cmd window. I know queues, stacks, binary search trees, how to create iterators and all that good stuff used for ordering and manipulating info. I just don't know app development or how to get input without halting everything.
OK, I'd say you should use threads (one constantly counting to a billion and one waiting for user input). Search google to find loads of tutorials and examples for thread programming.
As far as I know (but there's still a lot to learn about Java, so I could be wrong), listeners as known by Java, are only for GUIs, not for the command line (and therefore System.in).
Greetings,
Nepomuk
I believe you're correct about Listeners being GUI only. Threads are probably the way to go here...
I believe you're correct about Listeners being GUI only. Threads are probably the way to go here...
Listeners are a general purpose solution; they're not GUI only. Have a look
at the PropertyChangeSupport class for example: any bound property
can use it. And should use it most of the time to decouple parts of groups of
classes from eachother.
kind regards,
Jos
Sign in to post your reply or Sign up for a free account.
Similar topics
by: C. Schwerdtfeger |
last post by:
Hi group.
I'm trying to use DCOM with Java, but haven't found any help searching
the list, all entries where about 2 years of age or older, so I'm
posting ;)
* I've read in a posting from '97...
|
by: gg |
last post by:
I was playing with some free java code but I was miffed.
In the current working directory, I have xyz.jar and a subdirectory
coresrvlets. The classes of the package coreservlets are naturally...
|
by: news |
last post by:
My question is for the software, IDE and programming in general.
Is there an add-in or a program that is similiar to the search bar function
in the Office Xp software where you type in any...
|
by: F. GEIGER |
last post by:
I've dev'ed a Python prototype of an app, that besides the internals making
it up has a gui. While test-driven dev'ing the app's internals in Python is
fun as usual, dev'ing the GUI is not so...
|
by: Tim923 |
last post by:
The code in C# looks very similiar to what I remember from Java, but
we haven't done much manual coding yet. How similiar are they?
|
by: wellstone9912 |
last post by:
Java programmers seem to always be whining about how confusing and
overly complex C++ appears to them. I would like to introduce an
explanation for this. Is it possible that Java programmers...
|
by: helpwithcode |
last post by:
Hi people,
I am just learning java.I have been creating a project which involves JDBC Connectivity.I find that the statements,
String string_dob=text_dob.getText();
//Converting string to...
|
by: slikrik98 |
last post by:
Greetings,
I have an application that subscribes to an intensive data feed, constantly receiving messages, and then routes those messages to various "listeners." My first attempt was to just...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |