Results 1 to 2 of 2
  1. #1
    coco is offline Member
    Join Date
    Jul 2007
    Posts
    39
    Rep Power
    0

    Default Implements MyClass extends JFrame

    Hi, Can someone tell me what is implements mean??

    Java Code:
    import java.awt.*;
    import java.awt.event.*;
    public class MyClass extends JFrame implements ActionListener{
    I understand what extends mean (super class and sub class), but what is implements mean?
    Thanks.

  2. #2
    hardwired's Avatar
    hardwired is offline Senior Member
    Join Date
    Jul 2007
    Posts
    1,576
    Rep Power
    9

    Default

    implements is for interfaces as opposed to classes which we extend.
    When a class implements an interface it must provide an implementation of each and every method defined by the interface. The implementation can be empty but the method signature must appear inside the class.
    Examples:
    Java Code:
    public class MyClass extends JFrame implements ActionListener {
        public void actionPerformed(ActionEvent e) {
        }
    }
    
    public class Pseudo implements Runnable {
        public void run() {
        }
    }
    
    class Pseudo implements MouseMotionListener {
        public void mouseDragged(MouseEvent e) {
            // code for dragging in this component
        }
    
        public void mouseMoved(MouseEvent e) {
            // empty implementation - no code
        }
    }
    You can look up the interface in the api/javadocs to see which methods are defined.

Similar Threads

  1. Add an image to JFrame
    By Eranga in forum AWT / Swing
    Replies: 4
    Last Post: 02-01-2010, 03:09 PM
  2. JFrame problem
    By vassil_zorev in forum AWT / Swing
    Replies: 1
    Last Post: 01-25-2008, 02:53 AM
  3. JFrame Question ?
    By Mindhunter74 in forum New To Java
    Replies: 2
    Last Post: 12-21-2007, 10:45 PM
  4. How to implements cryptation in a java
    By paul in forum Advanced Java
    Replies: 1
    Last Post: 08-07-2007, 05:06 AM
  5. Help with JFrame
    By Albert in forum AWT / Swing
    Replies: 2
    Last Post: 07-04-2007, 04:44 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •