Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / February 2006

Tip: Looking for answers? Try searching our database.

Basic event handling

Thread view: 
Colin Hemmings - 17 Feb 2006 13:12 GMT
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.



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.