I really don't understand what I'm doing wrong. I've made windows before..and never have had this problem. The code complies fine, but when I run it I get this message..

java.lang.NoClassDefFoundError: smartMonster
Exception in thread "main"

right now all I want is a window to pop up with a button. I'm guessing it's an easy fix..but I've been working on it for awhile.

import java.io.File;
import static java.lang.System.out;
import java.util.*;
import java.io.IOException;
import java.io.PrintStream;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

class smartMonsterWindow extends JFrame
{
	private JButton run;

	
	public static void main (String args[])
	{
		JFrame smartMonsterWindow = new JFrame();
		smartMonsterWindow.show();
	//	run();
	}	
	
	
	public smartMonsterWindow() //INSIDE WINDOW
	{
	
		//Make the Window
		setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
		setTitle ("SmartMonster");
		setSize (200,300);
		setLocation (80,50);

		//Add the components
		Container contentPane = getContentPane();
		contentPane.setLayout(new GridLayout (2, 2, 3, 3));
			
		out.println ("Test");
		//contentPane.add(new JLabel("this is a test"));
		JButton run = new JButton( "RUN" );
        		contentPane.add(run);
				
	}
}

Ok..nevermind. I just spent a hour on this because I changed the name of the class without changing the .java file name.

sorry for posting =/

This article has been dead for over six months. Start a new discussion instead.