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 have another probleam with my coding. The probleam is my coding have an error cannot find symbol. Here i attach my coding and i also highlight the line which cause me an error

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

public class ButangWarna extends Frame implements ActionListener {
JButton Bmerah, Bhijau;
public static void main(String arg[])
{
ButangWarna f = new ButangWarna("Background Colour"); /* cannot find symbol*/
f.addWindowListener(new WindowEventHandler());
f.setSize(400,200);
f.setVisible(true);
}

public void BiodataPelajar(String str)
{
Super(str);
setLayout(new FlowLayout());

Bmerah = new JButton("RED");
Bhijau = new JButton("Green");
add(Bmerah);
add(Bhijau);
Bmerah.addActionListener(this);
Bhijau.addActionListener(this);
}

public void actionPerformed(ActionEvent e)
{
Object pilihan = e.getSource();
Color warna= getBackground();

if (pilihan ==Bmerah)
{
warna=Color.red;

}
else

if(pilihan==Bhijau)
{
warna=Color.green;
}
setBackground(warna);
repaint();
}
}

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.
cush50
Offline
Joined: 2011-10-24

hi swan...

Try the attatched code. i am not too sure about the implications of the super constructor .. so i have just comented it out,

and also added a string parameter to the constructor; . it comnpiles for me. and runs i hope you can compile and run it too.

Happy coding cush;;