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 / GUI / June 2005

Tip: Looking for answers? Try searching our database.

JButton inputStream to System.in

Thread view: 
blaine@worldweb.com - 29 Jun 2005 22:49 GMT
Hello,

I have an applet that I would like to gather the keyboard input once
someone clicks on the JButton. At first I thought that I could just
read System.in, but that provided no solution. I have since found that
to get the input once the JButton has focus it needs to have a
KeyListener added. However I would like to push the KeyListener
keyTyped character to the System Input Stream.

Any ideas on how I can do this?

My best guess, but does not work is below.

   public void addJButton(){
        JButton jbtNext = new JButton("Click Here To Take Keyboard
Input");
        jbtNext.setEnabled(true);
        jbtNext.setName("scan keyboard");
        this.validate();

        //Register Listener
        jbtNext.addKeyListener(this);

        //System.setIn( jbtNext.someHowGetInputStream() );
   }

   public void keyTyped(KeyEvent e){
       char key = e.getKeyChar();
       System.out.println("Key: >" + key + "<");

       //Somehow put character on System Input Stream

   }
Andrew Thompson - 29 Jun 2005 23:23 GMT
> I have an applet that I would like to gather the keyboard input ...

Why?  What do you want to achieve?

Will the end user* accept a signed Java
applet to get this functionality?

* I care more about them, than developers..  ;-)

[ Note - follow-ups set to c.l.j.gui *only* ]

Signature

Andrew Thompson
http://www.PhySci.org/codes/  Web & IT Help
http://www.PhySci.org/  Open-source software suite
http://www.1point1C.org/  Science & Technology
http://www.LensEscapes.com/  Images that escape the mundane

blaine@worldweb.com - 30 Jun 2005 15:22 GMT
What I'm trying to achive is to get the keybord input as an Input
Stream so that I can pass this input stream to another class to write
this input to the RS232 Stream.

Yes, it is a signed applet.
Andrew Thompson - 30 Jun 2005 15:41 GMT
> What I'm trying to achive is to get the keybord input as an Input
> Stream so that I can pass this input stream to another class to write
> this input to the RS232 Stream.

(shakes head slowly)  ..and what does that *do*?

> Yes, it is a signed applet.

OK.  Thank you for clarifying, but I am wonderring why you
keep saying the 'keyboard input stream' specifically.

If your users want to pass information to the RS232, give
them a TextField to type the information, that way it is
much easier for your class to collect and process the
commands.

But please explain what exactly happens between the start
and end - I still do not understand what you are trying to
give to the user, and there may be better ways to do
whatever that is.

Signature

Andrew Thompson
http://www.PhySci.org/codes/  Web & IT Help
http://www.PhySci.org/  Open-source software suite
http://www.1point1C.org/  Science & Technology
http://www.LensEscapes.com/  Images that escape the mundane



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.