java.lang.Error: Unresolved compilation problems
I'm having a bit of trouble with this code...any ideas?
:confused:
Code:
[B]BuggyButtonTest.java[/B]
package homenetwork.bkr.training;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class BuggyButtonTest {
public static void main(String[] args)
{
EventQueue.invokeLater(new Runnable()
{
public void run()
{
BuggyButtonFrame frame = new BuggyButtonFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
});
}
}
[B]BuggyButtonFrame.java[/B]
package homenetwork.bkr.training;
public class BuggyButtonFrame extends JFrame {
public BuggyButtonFrame()
{
setTitle("Buggy Button Test");
setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT);
//add panel to the frame
BuggyButtonPanel panel = new BuggyButtonPanel();
add(panel);
}
public static final int DEFAULT_WIDTH = 300;
public static final int DEFAULT_HEIGHT = 200;
}
[B]BuggyButtonPanel.java[/B]
package homenetwork.bkr.training;
import java.awt.event.ActionEvent;
import javax.swing.JButton;
public class BuggyButtonPanel extends JPanel {
public BuggyButtonPanel()
{
ActionListener listener = new ButtonListener();
JButton yellowButton = new JButton("Yellow");
add(yellowButton);
yellowButton.addActionListener(listener);
JButton blueButton = new JButton("Blue");
add(blueButton);
blueButton.addActionListener(listener);
JButton redButton = new JButton("Red");
add(redButton);
redButton.addActionListener(listener);
}
}
private class ButtonListener implements ActionListener
{
public void actionPerformed(ActionEvent event)
{
String arg = event.getActionCommand();
if (arg.equals("yellow")) setBackground(Color.yellow);
else if (arg.equals("blue")) setBackground(Color.blue);
else if (arg.equals("red")) setBackground(Color.red);
}
}
Errors:
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
The method setDefaultCloseOperation(int) is undefined for the type BuggyButtonFrame
The method setVisible(boolean) is undefined for the type BuggyButtonFrame
at homenetwork.bkr.training.BuggyButtonTest.main(Bugg yButtonTest.java:15)