Can anybody tell me why this isnt working. I get two error both saying
"cannot find symbol" I have denoted them witha comment
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
/**
* Write a description of class gridLayout here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class gridLayout extends JFrame implements ActionListener
{
private JPanel grid = new JPanel( new GridLayout(3, 3));
public void actionPerformed(ActionEvent event)
{
System.out.println("Item: " + event.getActionCammand());
// get an error here saying "cannot find symbol"
System.out.println("Item: ");
}
public gridLayout()
{
JPanel panel1 = new JPanel();
JLabel labelOne = new JLabel("one");
//labelOne.addActionListener(this);
// get an error here saying "cannot find symbol"
panel1.add(labelOne);
grid.add(panel1);
grid.add(new JButton("2"));
grid.add(new JButton("3"));
grid.add(new JButton("4"));
grid.add(new JButton("5"));
grid.add(new JButton("6"));
grid.add(new JButton("7"));
grid.add(new JButton("8"));
grid.add(new JButton("9"));
//JTabbedPane tp = new JTabbedPane();
//tp.addTab("Grid", grid);
setContentPane(grid);
setSize(300,175);
setVisible(true);
}
}
Thomas Weidenfeller - 17 Feb 2006 13:23 GMT
> Can anybody tell me why this isnt working. I get two error both saying
> "cannot find symbol" I have denoted them witha comment
> System.out.println("Item: " + event.getActionCammand());
> // get an error here saying "cannot find symbol"
Spelling error Command, not Cammand.
> //labelOne.addActionListener(this);
> // get an error here saying "cannot find symbol"
A label doesn't have an addActionListener() method.
/Thomas

Signature
The comp.lang.java.gui FAQ:
ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq
http://www.uni-giessen.de/faq/archiv/computer-lang.java.gui.faq/
Colin Hemmings - 17 Feb 2006 17:11 GMT
ok, thanks for that, is there not a mouse click event for a label then?
>> Can anybody tell me why this isnt working. I get two error both saying
>> "cannot find symbol" I have denoted them witha comment
[quoted text clipped - 10 lines]
>
> /Thomas
zero - 17 Feb 2006 18:02 GMT
Colin Hemmings <colin.hemmings1@ntlworld.com> wrote in news:ttnJf.5118
$bw1.4887@newsfe2-win.ntli.net:
> ok, thanks for that, is there not a mouse click event for a label then?
use Component:addMouseListener(MouseListener)
Thomas Weidenfeller - 20 Feb 2006 09:01 GMT
> ok, thanks for that, is there not a mouse click event for a label then?
The API documentation easily answers such questions.
/Thomas
Roedy Green - 18 Feb 2006 22:31 GMT
On Fri, 17 Feb 2006 13:13:59 GMT, Colin Hemmings
<colin.hemmings1@ntlworld.com> wrote, quoted or indirectly quoted
someone who said :
> JLabel labelOne = new JLabel("one");
> //labelOne.addActionListener(this);
>// get an error here saying "cannot find symbol"
JLabels are inert things. They don't generate
ActionEvents. Perhaps you meant JButton?

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.