I am trying to run the following code on my computer, and it is giving me static, even though I have personally seen this exact code run on my friends computer correctly....
On my computer it is giving me complaints about not being able to recognize the main class when I try to compile and run the code:
errorz2.JPG
As I said, Mark can run this code, without any changes on his laptop, and he gets a box with two buttons in it, but my computer won't even compile the code properly??
Here is the code, in the hopes that someone can see what is going wrong for me:
Can someone see where I am getting my errors here??import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; class SwingApp { private JButton action1; private JButton action2; private JLabel actionLabel; SwingApp() { // create JFrame container JFrame mainFrame = new JFrame( "Example Container Application" ); mainFrame.setLayout(new FlowLayout()); // set the initial size mainFrame.setSize( 220, 100 ); // terminate the app when the user exits mainFrame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE ); // create button and label actionLabel = new JLabel( "This is a label that will change" ); action1 = new JButton( "action1" ); action2 = new JButton( "action2" ); // add action listener for action1 using annonymous inner classes to // provide the event handlers when ActionEvent is fired action1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { actionLabel.setText("action button 1 pressed.");}}); // same for button 2 action2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { actionLabel.setText("action button 2 pressed.");}}); // add components to the JFrame container mainFrame.add( action1 ); mainFrame.add( action2 ); mainFrame.add( actionLabel ); // make our JFrame visible mainFrame.setVisible( true );}} public static void main(String[] args) { //THE MAIN CLASS IS RIGHT HERE!! SwingUtilities.invokeLater( new Runnable() { public void run() { new SwingApp();}});}