LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 05-24-2006, 02:36 PM   #1
alred
Member
 
Registered: Mar 2005
Location: singapore
Distribution: puppy and Ubuntu and ... erh ... redhat(sort of) :( ... + the venerable bsd and solaris ^_^
Posts: 658
Blog Entries: 8

Rep: Reputation: 31
how to avoid writing every methods for a listener in a java program ??


how to avoid writing every methods for a listener in a java program ?? for eg. a mouse or a window listener

any links with small example codes if possible ...


thanks in advance ...



.
 
Old 05-24-2006, 06:09 PM   #2
paulsm4
Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
The standard Java libraries provide a bunch of so-called "Adapter classes". You just subclass the adapter, and override only those methods you're interested in changing.

Here's an example (MouseInputAdapter):

http://java.sun.com/docs/books/tutor...elistener.html

PS:
You definitely do *not* want to monitor low-level events like keystrokes or mouse motion, if you can accomplish the same goal with a higher-level "action listener" on a UI component (e.g. "button click").
 
Old 05-24-2006, 11:41 PM   #3
alred
Member
 
Registered: Mar 2005
Location: singapore
Distribution: puppy and Ubuntu and ... erh ... redhat(sort of) :( ... + the venerable bsd and solaris ^_^
Posts: 658
Blog Entries: 8

Original Poster
Rep: Reputation: 31
its working now ...

thanks ...

PS :: will not monitor low-level events like keystrokes or mouse motion ...


.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Stop java program(threaded program..should end cleanly) rmanocha Programming 4 11-09-2004 10:36 AM
difference between Java compare and compareTo methods kpachopoulos Programming 2 09-19-2004 05:08 AM
CD Writing program? Which is best? nro Linux - Software 14 09-01-2004 11:19 AM
java -- methods -- please help Laptop2250 Programming 2 12-13-2003 01:46 AM
Whats the best, free, program for writing and running Java oudent Programming 8 12-08-2001 07:18 AM


All times are GMT -5. The time now is 03:07 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration