Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 1st, 2012  |  syntax: None  |  size: 0.86 KB  |  hits: 17  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. ## error
  2.  
  3. 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
  4.         void actionPerformed(ActionEvent e)
  5.              ^
  6. 1 error
  7.  
  8. ## code
  9.  
  10. import java.awt.event.*;
  11. import javax.swing.*;
  12.  
  13. class MyButton extends JButton implements ActionListener
  14. {
  15.         MyButton(String s) {
  16.                 super(s);
  17.                 addActionListener(this);
  18.         }
  19.  
  20.         void actionPerformed(ActionEvent e)
  21.         {
  22.                 setEnabled(false);
  23.         }
  24. }
  25.  
  26. public class Grey
  27. {
  28.         public static void main(String[] args)
  29.         {
  30.                 JFrame frame    = new JFrame("Greyed Out");
  31.                 MyButton btn    = new MyButton("Grey me out bitch");
  32.  
  33.                 frame.getContentPane().add(btn);
  34.                 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  35.                 frame.setSize(200, 100);
  36.                 frame.setVisible(true);
  37.         }
  38. }