Basically my problem is that I've been able to create the buttons, but am unable to get any of the text to show up on the buttons, nor for the event listener to work. Any help would be greatly appreciated.
public class LifeButton extends JButton
private String text ;
private boolean value ;
private int x ;
private int y ;
public LifeButton( String text, boolean value, int x, int y )
System.out.println( "Initializing button " + x + " " + y ) ;
this.text = text ;
this.value = value ;
this.x = x ;
this.y = y ;
public void button()
System.out.println( "in button " + x + " " + y ) ;
final JButton myButton = new JButton( text ) ;
class ClickListener implements ActionListener
public void actionPerformed( ActionEvent event )
System.out.println( "in button action " + x + " " + y ) ;
if( value )
value = false ;
text = "0" ;
value = true ;
text = "X" ;
The problem with the button text is that you're not displaying the buttons that have the text. You have defined a LifeButton subclass of JButton, and you display these on a panel, but for some reason, in the button() method (not a very descriptive name), you create a new JButton and put the text and action listener into that. At the end of the button() method, this new button goes out of scope and takes the text and the action listener with it to oblivion.
I suggest you simply remove all references to 'myButton' in the button() method.
At the source of every error which is blamed on the computer, you will find at least two human errors, one of which is the error of blaming it on the computer...
Please use [CODE]...your code here...[/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.