Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: error :cannot find symbol

  1. #1
    Junior Member
    Join Date
    Sep 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default error :cannot find symbol

    Hai, i got an error cannot symbol in my coding. Please help me to correct my coding please. I also highlight the line which give me an error





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

    public class Jantina extends Frame implements ActionListener { /* error Jantina is not abstract and does not override abstract method actionPerformed*/
    JButton Btentu;
    JTextField Tnoic, TJantina;
    JLabel Lnoic, LJantina,LTajuk;

    public static void main(String args[])
    {
    Jantina j = new Jantina("Jantina");
    j.addWindowListener(new WindowEventhandler()); /*error non-static variable this cannot be referenced from a static context*/
    j.setSize(200,250);
    j.setVisible(true);
    }


    public Jantina(String str)
    {
    Super(str); /* error cannot find symbol*/
    setLayout(new FlowLayout());
    setLayout( new FlowLayout(FlowLayout.CENTER));
    LTajuk = new JLabel("No Kad Pengenalan :");
    Tnoic = new JTextField(15);
    LJantina = new JLabel ("jantina");
    TJantina = new JTextField(15);
    Btentu = new JButton("Tentu");


    }

    public void actionPerforemed(ActionEvent e)
    {
    Object pilihan = e.getSource();
    long nilai, noic;
    noic = Long.parseLong(Tnoic.getText());
    nilai = noic%2;
    if ( nilai == 0)
    TJantina.setText("Perempuan");
    else
    TJantina.setText("Lelaki");

    }

    class WindowEventhandler extends WindowAdapter
    {
    public void WindowClosing(WindowEvent e)
    {

    System.exit(0);
    }
    }
    }


  2. #2
    Super Moderator Sean4u's Avatar
    Join Date
    Jul 2011
    Location
    Tavistock, UK
    Posts
    637
    Thanks
    5
    Thanked 103 Times in 93 Posts

    Default Re: error :cannot find symbol

    Selamat datang ke JPFs.com iswan!

    Post your code in code tags - see the BBCode link below:
    BB Code List - Java Programming Forums
    [highlight=java]/* your code */[/highlight] will make it more readable.

    You've got 3 different kinds of errors.
    If you want your Frame / Jantina to implement the ActionListener interface, you have to implement the methods in that interface in Jantina

    The second error appears to be an error in an error in an error. There's a CamelCaseClassName capitalisation issue, a missing anonymous inner class implementation - and there's no WindowEventHandler in my copy of the Java API. Where did you get that class name from?

    The third one's a bit easier - java statements are all lower case.

Similar Threads

  1. NEW TO PROGRAMMING, PLEASE HELP (cannot find symbol error)
    By bluescholar in forum What's Wrong With My Code?
    Replies: 2
    Last Post: August 26th, 2011, 04:48 PM
  2. Cannot find Symbol?
    By defmetalhead in forum What's Wrong With My Code?
    Replies: 8
    Last Post: July 5th, 2011, 08:48 AM
  3. Cannot find symbol error
    By AnuR in forum What's Wrong With My Code?
    Replies: 9
    Last Post: February 23rd, 2011, 02:50 PM
  4. cannot find symbol Error
    By bananasplitkids in forum What's Wrong With My Code?
    Replies: 2
    Last Post: March 9th, 2010, 02:36 AM
  5. Replies: 2
    Last Post: November 3rd, 2009, 06:28 AM