
Untitled
By: a guest on
Jul 1st, 2012 | syntax:
None | size: 0.86 KB | hits: 17 | expires: Never
## error
Grey.java:11: actionPerformed(java.awt.event.ActionEvent) in MyButton cannot implement actionPerformed(java.awt.event.ActionEvent) in java.awt.event.ActionListener; attempting to assign weaker access privileges; was public
void actionPerformed(ActionEvent e)
^
1 error
## code
import java.awt.event.*;
import javax.swing.*;
class MyButton extends JButton implements ActionListener
{
MyButton(String s) {
super(s);
addActionListener(this);
}
void actionPerformed(ActionEvent e)
{
setEnabled(false);
}
}
public class Grey
{
public static void main(String[] args)
{
JFrame frame = new JFrame("Greyed Out");
MyButton btn = new MyButton("Grey me out bitch");
frame.getContentPane().add(btn);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(200, 100);
frame.setVisible(true);
}
}