Skip to main content
GameDev.net gamedev.net
🔒 Locked

[java] input in JAVA applets

Started by krez Oct 16, 2001 at 8:20 PM 3 replies 400+ views
Original Post
krez
krez
i have just started "playing" with java, and i have a few newbie question... just to get me started, i am trying to write a terminal applet (later i might turn it into a MUD or something along those lines, or i might learn it and then throw it out, i don''t know yet)... but i have a few problems: (1) how do you get input for an applet? i was planning on storing several strings, for the lines already on the terminal, and another for the last line where the user input is shown. i found a tutorial about keyup and mousedown events and such, but my compiler says i am using a deprecated API, so there must be a better newer and accepted way to do this? (2) how do i make the applet update the screen? right now, it only updates when i switch to another window that covers the applet box, then switch back. how do i make it update? for example, every time i press a key it should add one character to my string and then re-draw the screen so the new string is displayed. i''d appreciate any help. thanks in advance --- krez (krezisback@aol.com)
--- krez ([email="krez_AT_optonline_DOT_net"]krez_AT_optonline_DOT_net[/email])
WayfarerX
WayfarerX
1) What you want is to use the event listener model introduced with JDK1.1. Check out the Java Tutorial page on how to do this: Java Tutorial: Writing Event Listeners.

2) What you're looking for is the repaint() method. Call it inside your applet and it will clear the screen, then it will call your paint() method where you re-draw the screen.

"If consquences dictate our course of action, it doesn't matter what's right, it's only wrong if you get caught."
- Tool



Edited by - WayfarerX on October 17, 2001 11:15:16 AM
"There is no reason good should not triumph at least as often as evil. The triumph of anything is a matter of organization. If there are such things as angels, I hope that they're organized along the lines of the mafia." -Kurt Vonnegut
krez
krez
much obliged

--- krez (krezisback@aol.com)
--- krez ([email="krez_AT_optonline_DOT_net"]krez_AT_optonline_DOT_net[/email])
wrenhal
wrenhal
quote:
Original post by krez
i have just started "playing" with java, and i have a few newbie question...
just to get me started, i am trying to write a terminal applet (later i might turn it into a MUD or something along those lines, or i might learn it and then throw it out, i don''t know yet)... but i have a few problems:
(1) how do you get input for an applet? i was planning on storing several strings, for the lines already on the terminal, and another for the last line where the user input is shown. i found a tutorial about keyup and mousedown events and such, but my compiler says i am using a deprecated API, so there must be a better newer and accepted way to do this?
(2) how do i make the applet update the screen? right now, it only updates when i switch to another window that covers the applet box, then switch back. how do i make it update? for example, every time i press a key it should add one character to my string and then re-draw the screen so the new string is displayed.
i''d appreciate any help. thanks in advance

--- krez (krezisback@aol.com)



I haven''t really messed with Input yet, but I do know that you have to call repaint() for the screen to update.


BeS
It''s Da BOMB Baby!!!
. o O ~
A little nonsense now and then,
is relished by the wisest men
~ O o .
-- Willy Wonka

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.