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);
}
}
}
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.