Skip to main content

Error: Cannot find symbol

Please note these java.net forums are being decommissioned and use the new and improved forums at https://community.oracle.com/community/java.
1 reply [Last post]
iswan
Offline
Joined: 2011-09-30

Hai , i got an error in my coding such cannot find symbol .Please help correct my coding.I also highlight the line which cause me a probleam.

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

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

public static void main(String args[])
{
Jantina j = new Jantina("Jantina"); /*cannot find symbol*/
j.addWindowListener(new WindowEventhandler()); /*non static variable this cannot be reference*/
j.setSize(200,250);
j.setVisible(true);
}

public void Jantina(String str)
{
Super(str); /*cannot find a symbol*/
setLayout(new FlowLayout());
setLayout(new FlowLayout(FlowLayout.Center)); /*cannot find symbol*/
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);
}
}
}

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
amitsoni1234
Offline
Joined: 2011-10-07

Hi,

first thing super keyword you use to call the baseclass constructor is misspelled it should be in lower case like super so your program is showing error message 'cannot find symbol".