Re: Using implements Runnable and MouseListener

From: Chris (chris2k01_at_hotmail.com)
Date: 02/07/04

  • Next message: Y2KYZFR1: "Re: Announcing new scripting/prototyping language"
    Date: Sat, 07 Feb 2004 20:10:06 GMT
    
    

    -----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
    > courses@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+BfNVa+7AKigCgql6r
    cTiNtMqFqYlkeQ55JTD83Kk=
    =lTT8
    -----END PGP SIGNATURE-----


  • Next message: Y2KYZFR1: "Re: Announcing new scripting/prototyping language"

    Relevant Pages

    • Re: Using implements Runnable and MouseListener
      ... > and also an applet which detects left, right and double mouse clicks using ... > detect the mouse actions as well as do some timing. ... > implements Runnable and MouseListener in the same Java applet? ...
      (comp.lang.java)
    • Using implements Runnable and MouseListener
      ... I am fairly new to Java but have written an applet that uses 'implements ... detect the mouse actions as well as do some timing. ... implements Runnable and MouseListener in the same Java applet? ...
      (comp.lang.java)
    • Pausing Threads From Events
      ... someone has some pointers for my problem. ... an applet which starts a new thread A. The applet implements ... MouseListener and when the user puts the mouse over the applet, ... When a user generates this MouseEntered event, ...
      (comp.lang.java.programmer)
    • Pausing Threads From Events
      ... someone has some pointers for my problem. ... an applet which starts a new thread A. The applet implements ... MouseListener and when the user puts the mouse over the applet, ... When a user generates this MouseEntered event, ...
      (comp.lang.java.help)
    • Mouse in a applet
      ... I am trying to make an applet so that when my mouse enters the applet ... the text will hover around it until it leaves the applet box. ... public class ClickName extends Applet implements MouseListener ...
      (comp.lang.java.programmer)