AppletTalk.com Forum Index AppletTalk.com
Java discussions newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

listener questions

 
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java GUI Toolkits
View previous topic :: View next topic  
Author Message
Emmanuel Freund
Guest





PostPosted: Fri Nov 26, 2004 9:50 am    Post subject: listener questions Reply with quote



I would like to have some key and mouse listeners with particular actions
for all my components "myButton", "myList", "myTextPane", etc... which
derivate from JButton, JList, JTextPane and so on, and always do the same
things.
For example, the keyAdapter would be like

public class myKeyAdapter extends KeyAdapter {
Component adaptee;

public myKeyAdapter(Component adaptee) {
this.adaptee = adaptee;
}

public void keyPressed(KeyEvent e) {
System.out.println("KeyEvent"+e);
}
}

One purpose of this is to implement a screen saver.
The problem is: I don't want to add this keyAdapter on all of my components.
So, since we cannot write code in an Interface (am I right?), since I cannot
derivate the component to myComponent because myButton is a child of
JButton, and since if I had the keyAdapter to the containers of those
components (say myFrame), it is not called when we are on the component
itself (for exemple when we write something in a JTextPane, no KeyPressed
event is given to the frame which contains the JTextPane), how can we
achieve that?
or where am I wrong?

Thanks for any help.

--
Emmanuel Freund
[email]efreund (AT) noos (DOT) fr[/email]


Back to top
Andrew Thompson
Guest





PostPosted: Fri Nov 26, 2004 10:13 am    Post subject: Re: listener questions Reply with quote



On Fri, 26 Nov 2004 10:50:08 +0100, Emmanuel Freund wrote:

Quote:
...One purpose of this is to implement a screen saver.

Are you aware of..
<https://screensavers.dev.java.net/> ?

( I suspect you are, since the savers do not have a workable
exit on key event, but thought I'd mention just in case. )

--
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

Back to top
Emmanuel Freund
Guest





PostPosted: Fri Nov 26, 2004 11:20 am    Post subject: Re: listener questions Reply with quote




"Andrew Thompson" <SeeMySites (AT) www (DOT) invalid> a écrit dans le message de
news:1q6l3lari91jr.4ghrgwpsiqm2.dlg (AT) 40tude (DOT) net...
Quote:
On Fri, 26 Nov 2004 10:50:08 +0100, Emmanuel Freund wrote:

...One purpose of this is to implement a screen saver.

Are you aware of..
https://screensavers.dev.java.net/> ?

( I suspect you are, since the savers do not have a workable
exit on key event, but thought I'd mention just in case. )

Yes, I was aware that some things like that might exist, but thanks anyway
for the link, it could be helpful later Wink
But I need a "kind" of screen saver for my application, and I need to use
the key-mouse-others listeners for some others things, so the question still
remains.
Thanks to your attention,

--
Emmanuel



Back to top
Kari Ikonen
Guest





PostPosted: Sat Nov 27, 2004 10:19 am    Post subject: Re: listener questions Reply with quote

Emmanuel Freund wrote:

Quote:
One purpose of this is to implement a screen saver.

1) javax.swing.Timer
2) javax.swing.GlassPane
3) KeyboardFocusManager.addKeyEventDispatcher(KeyEventDispatcher)


Back to top
Display posts from previous:   
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java GUI Toolkits All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.