Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Java Error

Name: Anonymous 2009-03-19 19:19

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

public class TwoButtons extends JFrame implements ActionListener
{
  JButton redButton ;
  JButton grnButton ;

  // constructor for TwoButtons
  public TwoButtons(String title)                          
  {
    super( title );
   
    redButton = new JButton("Red");
    grnButton = new JButton("Green");
    redButton.setActionCommand( "red" );   // set the  command
    grnButton.setActionCommand( "green" ); // set the  command  

    // register the buttonDemo frame
    // as the listener for both Buttons.
    redButton.addActionListener( this );
    grnButton.addActionListener( this );    

    setLayout( new FlowLayout() );
    add( redButton );                     
    add( grnButton );
   
    setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );  
  }

  public void actionPerformed( ActionEvent evt)
  {
    // check which command has been sent
    if ( evt.getActionCommand().equals( "red" ) )
      getContentPane().setBackground(  Color.red  );   
    else
      getContentPane().setBackground( Color.green );   

    repaint();
  }

  public static void main ( String[] args )
  {
    TwoButtons demo  = new TwoButtons( "Click a Button" ) ;
   
    demo.setSize( 200, 150 );    
    demo.setVisible( true );     
  }
}


This is fucking gay. I'm trying to learn java from a fucking tutorial, and the only GUI example it gave me to practice off is giving me a fucking error. Can someone point it out?

Name: TTHBCARWTFT MEME FAN 2009-03-19 19:54

This thread has been closed and replaced with the following thread:

Subject:
Compiling Java code in a Python compiler
Name: Anonymous
Email:

It still doesn't work.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List