
-----------------------------------
xHoly-Divinity
Fri Apr 06, 2007 6:07 pm

Mouse Listener
-----------------------------------
Can I use mouseListener in an applet (runnable), or do i have to use a JFrame/JApplet?

-----------------------------------
ericfourfour
Fri Apr 06, 2007 11:50 pm

RE:Mouse Listener
-----------------------------------
Mouse listeners work with all components I believe.

-----------------------------------
xHoly-Divinity
Sat Apr 07, 2007 11:35 am

Re: Mouse Listener
-----------------------------------
Hmm.... is it possible to use a mouseListener in parallel with a runnable? Cuz i need both keyboard and mouse input?

-----------------------------------
Ultrahex
Sat Apr 07, 2007 1:22 pm

Re: Mouse Listener
-----------------------------------
xHoly-Divinity,
hey school chump,

yes you can use any component and use a mouselistener, keylistener, mousemotionlistener etc....

and yes you can run them in parallel using two threads, however you do not need this for the program you are doing.

just implement both into the same component / add them to the same component, and you will be fine, both will run at same time.

If you don't trust me.....


import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class DoubleListen
{
		public static void main (String args

-----------------------------------
wtd
Sat Apr 07, 2007 1:38 pm

RE:Mouse Listener
-----------------------------------
Learn about interfaces, and learn to read the java.sun.com API docs and you won't need to ask this question.  :)

-----------------------------------
xHoly-Divinity
Tue Apr 10, 2007 5:09 pm

Re: Mouse Listener
-----------------------------------
Thanks ultrahex :wink: . Hehe, i have it wrkin, i just don't wana display it in class just in case Jone gets mad and makes me do more work, lol.

Do u think I can do the whole thing in applet and not use JFrames?

-----------------------------------
ericfourfour
Tue Apr 10, 2007 9:10 pm

RE:Mouse Listener
-----------------------------------
You are not required to use swing when working with applets.

-----------------------------------
wtd
Wed Apr 11, 2007 12:03 am

RE:Mouse Listener
-----------------------------------
When Swing is available, why use vanilla AWT?

-----------------------------------
xHoly-Divinity
Wed Apr 11, 2007 5:35 pm

Re: RE:Mouse Listener
-----------------------------------
When Swing is available, why use vanilla AWT?

considering it... maybe towards the end of the project I can 'convert' it to swing bcuz right now I want to get the functionality and everything working and so if there's time in the end (since i've very little experience with swing =/)

-----------------------------------
xHoly-Divinity
Wed Apr 11, 2007 6:07 pm

Re: Mouse Listener
-----------------------------------
Is it possible to get actionListener and keyListener working together? I tried but when I add the actionListner, the keyListener doesn't work  :evil:

-----------------------------------
HellblazerX
Thu Apr 12, 2007 1:00 pm

RE:Mouse Listener
-----------------------------------
The two should work together.  When you say that the keyListener doesn't work, what do you mean by it?

-----------------------------------
xHoly-Divinity
Thu Apr 12, 2007 9:04 pm

Re: Mouse Listener
-----------------------------------
ahhhh figured it out... when u make the button e.g. add (myButton), u have to add it to the ActionListener AND the KeyListener. I forgot to add to KeyListener so that's why it didn't work :mrgreen:

-----------------------------------
HellblazerX
Fri Apr 13, 2007 7:23 am

Re: Mouse Listener
-----------------------------------
Lol!  Now it seems that my keyListener isn't working.  I implemented the interface, set up my methods, and added the keyListener.  Did I forget anything, cuz I don't think I did.
