473,414 Members | 1,709 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

Using implements Runnable and MouseListener

I am fairly new to Java but have written an applet that uses 'implements
Runnable' to do some timing
eg
public class Puzzle extends Applet implements Runnable
{ etc.

and also an applet which detects left, right and double mouse clicks using
'implements MouseListener'
eg
public class TestMouse extends Applet implements
MouseListner { etc.

I would now like to write an applet that uses both of these so that I can
detect the mouse actions as well as do some timing.

Could someone show me the structure that would be used to allow both
implements Runnable and MouseListener in the same Java applet? This is
probably quite obvious to a regular Java programmer but I am an old style
programmer trying to convert to Java.

Thank you.
Doug van Vianen
co*****@shaw.ca
Jul 17 '05 #1
3 6940
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Doug van Vianen wrote:
I am fairly new to Java but have written an applet that uses
'implements Runnable' to do some timing
eg
public class Puzzle extends Applet implements
Runnable
{ etc.

and also an applet which detects left, right and double mouse clicks
using 'implements MouseListener'
eg
public class TestMouse extends Applet implements
MouseListner { etc.

I would now like to write an applet that uses both of these so that
I can detect the mouse actions as well as do some timing.

Could someone show me the structure that would be used to allow both
implements Runnable and MouseListener in the same Java applet? This
is probably quite obvious to a regular Java programmer but I am an
old style programmer trying to convert to Java.

Thank you.
Doug van Vianen
co*****@shaw.ca


Hi,
Although a class can only *extend* one other class, it can *implement*
any number of interfaces:

public class MyApplet extends Applet implements Runnable,
MouseListener {
....
}

Just keep adding more and more with commas until you have everything
you need.

- --
Chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (GNU/Linux)

iD8DBQFAJRvynwjA8LryK2IRAvcUAJ4xuNa2psgGsLgpN9+BfN Va+7AKigCgql6r
cTiNtMqFqYlkeQ55JTD83Kk=
=lTT8
-----END PGP SIGNATURE-----
Jul 17 '05 #2
"Doug van Vianen" <co*****@shaw.ca> wrote in message news:<hZaVb.416128$JQ1.297480@pd7tw1no>...
I am fairly new to Java but have written an applet that uses 'implements
Runnable' to do some timing
eg
public class Puzzle extends Applet implements Runnable
{ etc.

and also an applet which detects left, right and double mouse clicks using
'implements MouseListener'
eg
public class TestMouse extends Applet implements
MouseListner { etc.

I would now like to write an applet that uses both of these so that I can
detect the mouse actions as well as do some timing.

Could someone show me the structure that would be used to allow both
implements Runnable and MouseListener in the same Java applet? This is
probably quite obvious to a regular Java programmer but I am an old style
programmer trying to convert to Java.

Thank you.
Doug van Vianen
co*****@shaw.ca


The most typically, timing thread, which is your runnable, does some
sleep() and call applet's repaint() -- that is it is a controller for
some animation. MouseListener will do whatever it likes in its various
methods.
Jul 17 '05 #3

"Chris" <ch*******@hotmail.com> wrote in message
news:yCbVb.4075$964.1401@edtnps84...
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Doug van Vianen wrote:
I am fairly new to Java but have written an applet that uses
'implements Runnable' to do some timing
eg
public class Puzzle extends Applet implements
Runnable
{ etc.

and also an applet which detects left, right and double mouse clicks
using 'implements MouseListener'
eg
public class TestMouse extends Applet implements
MouseListner { etc.

I would now like to write an applet that uses both of these so that
I can detect the mouse actions as well as do some timing.

Could someone show me the structure that would be used to allow both
implements Runnable and MouseListener in the same Java applet? This
is probably quite obvious to a regular Java programmer but I am an
old style programmer trying to convert to Java.

Thank you.
Doug van Vianen
co*****@shaw.ca


Hi,
Although a class can only *extend* one other class, it can *implement*
any number of interfaces:

public class MyApplet extends Applet implements Runnable,
MouseListener {
...
}

Just keep adding more and more with commas until you have everything
you need.

- --
Chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (GNU/Linux)

iD8DBQFAJRvynwjA8LryK2IRAvcUAJ4xuNa2psgGsLgpN9+BfN Va+7AKigCgql6r
cTiNtMqFqYlkeQ55JTD83Kk=
=lTT8
-----END PGP SIGNATURE-----


Thank you, Chris. That is the simply, easy-to-follow answers that are
great!!

Doug
co*****@shaw.ca
Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Minti | last post by:
Hi there all, I am having a weird problem in the following Applet code, <begin code> public class MouseInputTester extends java.applet.Applet { private String msg = ""; private int mouseX ;...
0
by: Netveloper | last post by:
Hi, I'm playing around with url rewriting and I have come across a problem which I can't seem to get past. The general ide is to have a IHttpHandlerFactory class which checks the incoming...
6
by: gauravkhanna | last post by:
import java.io.*; class Automation1 implements Runnable { int iterationCount=0; Thread t; FileReader fr; //FileWriter fw; BufferedReader br; ...
6
by: Erick | last post by:
I've created a class called Procs and a collection class called Processes which uses a hastable object to store the Procs. Now i want to enumerate with the "For each" to extract all the Procs in...
1
by: NiponW | last post by:
Hi, Database Server running slow. I used SP_WHO2 ACTIVE and the result has many of XXXX SA RUNNABLE MASTER AWAITING COMMAND.......... (XXXX is spid) and they stay for couples seconds.
1
by: CodeSeeker | last post by:
I have an application, which uses pop3 to read the messages from the mailbox, and it has been working fine for so many year. We recently have started changing this application to use java mail IMAP 4...
1
by: piyushgpt1 | last post by:
My company has a web application running on JBoss-2.4.4_Tomcat-4.0.1. It works fine for a few days, but once or twice in a week, getting the exception :- Error : Runnable did not complete within...
7
by: =?Utf-8?B?QU9UWCBTYW4gQW50b25pbw==?= | last post by:
Hi, I have been using the code (some of it has been removed for simplicity) below to allow authenticated (using ASP.NET membership database) users to get a file from their archive area. It...
1
by: ragonz | last post by:
Hi, i'm kind of newbie in java programming. Now, i'm working on my task, n i hav a problem in using variable from other method. Here goes the code.. import java.awt.*; import java.awt.event.*;...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.