Newbie Question

Discussion in 'Java' started by Richard, Jan 8, 2004.

  1. Richard

    Richard Guest

    I have a JFrame that creates an instance of a class that is a
    subclass, of an abstract class, that is itself a subclass of JPanel.

    What I am trying to do is to add a button in the abstract classand
    then when it is clicked to go to a listener in the Jframe.

    Normally I would use
    myButton.addActionListener(this);
    but it does not even allow me to use this method, but this would not
    do what I want anyway. I think I am using the correct imports:

    import javax.swing.*;
    import java.awt.*;
    import java.lang.*;
    import java.awt.event.*;
    import javax.swing.event.*;

    Any help would be greatly received.
    Thanks
    Richard, Jan 8, 2004
    #1
    1. Advertising

  2. "Richard" <> wrote in message
    news:...
    > I have a JFrame that creates an instance of a class that is a
    > subclass, of an abstract class, that is itself a subclass of JPanel.
    >
    > What I am trying to do is to add a button in the abstract classand
    > then when it is clicked to go to a listener in the Jframe.
    >
    > Normally I would use
    > myButton.addActionListener(this);
    > but it does not even allow me to use this method, but this would not
    > do what I want anyway. I think I am using the correct imports:
    >
    > import javax.swing.*;
    > import java.awt.*;
    > import java.lang.*;
    > import java.awt.event.*;
    > import javax.swing.event.*;
    >
    > Any help would be greatly received.


    What error message does it give? Are you sure that the class containing
    myButton is an ActionListener? It should say implements ActionListener with
    the class declaration. Does it actually implement the actionPerformed
    method?

    Cheers,
    Matt Humphrey http://www.iviz.com/
    Matt Humphrey, Jan 8, 2004
    #2
    1. Advertising

  3. "Richard" <> wrote in message
    news:...
    | I have a JFrame that creates an instance of a class that is a
    | subclass, of an abstract class, that is itself a subclass of
    JPanel.

    Where is your code?
    http://www.physci.org/codes/sscce.jsp

    | import javax.swing.*;
    | import java.awt.*;
    | import java.lang.*;
    | import java.awt.event.*;
    | import javax.swing.event.*;

    That's a start..

    --
    Andrew Thompson
    * http://www.PhySci.org/ PhySci software suite
    * http://www.1point1C.org/ 1.1C - Superluminal!
    * http://www.AThompson.info/andrew/ personal site
    Andrew Thompson, Jan 9, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jerry C.
    Replies:
    8
    Views:
    229
    Uri Guttman
    Nov 23, 2003
  2. Kruno Saho
    Replies:
    0
    Views:
    134
    Kruno Saho
    Apr 7, 2013
  3. Dave Angel
    Replies:
    0
    Views:
    118
    Dave Angel
    Apr 7, 2013
  4. rusi
    Replies:
    0
    Views:
    108
  5. Miki Tebeka
    Replies:
    0
    Views:
    82
    Miki Tebeka
    Apr 7, 2013
Loading...

Share This Page