473,804 Members | 2,064 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

iD8DBQFAJRvynwj A8LryK2IRAvcUAJ 4xuNa2psgGsLgpN 9+BfNVa+7AKigCg ql6r
cTiNtMqFqYlkeQ5 5JTD83Kk=
=lTT8
-----END PGP SIGNATURE-----
Jul 17 '05 #2
"Doug van Vianen" <co*****@shaw.c a> wrote in message news:<hZaVb.416 128$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*******@hotm ail.com> wrote in message
news:yCbVb.4075 $964.1401@edtnp s84...
-----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)

iD8DBQFAJRvynwj A8LryK2IRAvcUAJ 4xuNa2psgGsLgpN 9+BfNVa+7AKigCg ql6r
cTiNtMqFqYlkeQ5 5JTD83Kk=
=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
2594
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 ; private int mouseY; static int i = 0;
0
1959
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 request url against a set of predefined rules and creates and return the appropriate IHttpHandler implementation. Inside the IHttpHandler implementations, the request is examined and
6
27705
by: gauravkhanna | last post by:
import java.io.*; class Automation1 implements Runnable { int iterationCount=0; Thread t; FileReader fr; //FileWriter fw; BufferedReader br; //BufferedWriter bw;
6
2766
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 my Processes class. As far as i can tell i need to implement an IEnuerator method to do this. But how ? 'Procs Class Public Class Procs Private _Id As Integer
1
4567
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
2939
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 instead of Pop3. Primary reason for that :- Is we want to better meet out SLA, so we have decided to go with the 2 instances of this application, and hence decided to use IMAP4 to concurrently accessing the mailboxes via IMAP4. My issues:- Now...
1
3928
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 10000ms. I need to provide an answer as why this is happening. It happens one or twice evrryweek, I restart the server and the problem gets resolved. Please help. When I see the nohup.out file, the detailed error message is as:- Last Checkin :...
7
2834
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 seems to work fine, however I noticed that no web log entry is added when a successful download occurs (normally a 200 HTTP status code, however, if there is an authorization failure, it gets logged). I have a logging routine that logs a successful...
1
2043
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.*; import javax.swing.*; public class Main{ public static void main(String args){ EventQueue.invokeLater(new Runnable(){
0
9716
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10604
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10354
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7643
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6870
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5536
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5675
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4314
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3005
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.