Newbie Question

R

Richard

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
 
M

Matt Humphrey

Richard said:
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 (e-mail address removed) http://www.iviz.com/
 
A

Andrew Thompson

| 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..
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top