Results 1 to 9 of 9
Thread: key listener
- 04-23-2011, 07:08 AM #1
Member
- Join Date
- Mar 2011
- Posts
- 45
- Rep Power
- 0
key listener
i want to write a program that should run at the background and say what time is it, every time keys "1" and "2" are pressed. i found class keylistener which tracks keys, but because i want my program to run at the background, window is going to be inactive, so is going to be the component to whom i will add actionlistener. what can i do? :S
- 04-23-2011, 07:12 AM #2
- Join Date
- Jan 2011
- Location
- Richmond, Virginia
- Posts
- 3,069
- Blog Entries
- 3
- Rep Power
- 7
I don't know all the details, but perhaps you can just not set the frame to be visible, it will be running but you won't see it. You can have a frame pop up with the time when the correct key is pressed.
- 04-23-2011, 07:15 AM #3
Member
- Join Date
- Mar 2011
- Posts
- 45
- Rep Power
- 0
But, if window will be inactive it will not react on the pressed key :S
- 04-23-2011, 07:24 AM #4
- Join Date
- Jan 2011
- Location
- Richmond, Virginia
- Posts
- 3,069
- Blog Entries
- 3
- Rep Power
- 7
Have you tried it? The window is active, it's just not visible, try it out and see what happens. Perhaps to test, just print to the console when some key is pressed.
- 04-23-2011, 08:14 AM #5
Senior Member
- Join Date
- Jan 2011
- Location
- Rizal Province, Philippiines
- Posts
- 167
- Rep Power
- 0
#1. You can use add this to your constructor:
Java Code:setAlwaysOnTop(true);
- 04-23-2011, 08:51 AM #6
Can't be done in Java. An inactive window doesn't receive system events.
db
- 04-23-2011, 09:09 AM #7
Member
- Join Date
- Mar 2011
- Posts
- 45
- Rep Power
- 0
And is there any way to activate the window by pressing combination of keys :S But, obviously, it's the same :X
- 04-23-2011, 09:15 AM #8
- Join Date
- Jan 2011
- Location
- Richmond, Virginia
- Posts
- 3,069
- Blog Entries
- 3
- Rep Power
- 7
@db, for my own personal knowledge, can an invisible frame receive key input? Normally I would try myself but I can't access a computer for about 4 hours.
I'm wondering if it can listen for a certain key to be pressed, and when it fires the event can the listener open another window?
- 04-23-2011, 09:36 AM #9
Member
- Join Date
- Mar 2011
- Posts
- 45
- Rep Power
- 0
Similar Threads
-
GUI Listener not Listening
By m_patten2 in forum AWT / SwingReplies: 2Last Post: 11-24-2010, 01:06 AM -
Action Listener
By greatmajestics in forum AWT / SwingReplies: 8Last Post: 03-25-2010, 05:39 PM -
Tab Listener
By teckno101 in forum AWT / SwingReplies: 2Last Post: 09-29-2009, 09:40 PM -
Regarding Listener
By adeeb in forum AWT / SwingReplies: 2Last Post: 06-20-2008, 11:07 PM -
Regarding Listener
By adeeb in forum AWT / SwingReplies: 2Last Post: 06-10-2008, 02:00 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks