Java Homework help...JFrame

Reply

Join Date: Nov 2007
Posts: 25
Reputation: rickster11 is an unknown quantity at this point 
Solved Threads: 0
rickster11 rickster11 is offline Offline
Light Poster

Java Homework help...JFrame

 
0
  #1
Mar 6th, 2008
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.


  1.  
  2. import java.io.File;
  3. import static java.lang.System.out;
  4. import java.util.*;
  5. import java.io.IOException;
  6. import java.io.PrintStream;
  7. import javax.swing.*;
  8. import java.awt.*;
  9. import java.awt.event.*;
  10.  
  11. class smartMonsterWindow extends JFrame
  12. {
  13. private JButton run;
  14.  
  15.  
  16. public static void main (String args[])
  17. {
  18. JFrame smartMonsterWindow = new JFrame();
  19. smartMonsterWindow.show();
  20. // run();
  21. }
  22.  
  23.  
  24. public smartMonsterWindow() //INSIDE WINDOW
  25. {
  26.  
  27. //Make the Window
  28. setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
  29. setTitle ("SmartMonster");
  30. setSize (200,300);
  31. setLocation (80,50);
  32.  
  33. //Add the components
  34. Container contentPane = getContentPane();
  35. contentPane.setLayout(new GridLayout (2, 2, 3, 3));
  36.  
  37. out.println ("Test");
  38. //contentPane.add(new JLabel("this is a test"));
  39. JButton run = new JButton( "RUN" );
  40. contentPane.add(run);
  41.  
  42. }
  43. }
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 25
Reputation: rickster11 is an unknown quantity at this point 
Solved Threads: 0
rickster11 rickster11 is offline Offline
Light Poster

Re: Java Homework help...JFrame

 
0
  #2
Mar 6th, 2008
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 =/
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 6,143
Reputation: jwenting is just really nice jwenting is just really nice jwenting is just really nice jwenting is just really nice 
Solved Threads: 213
Team Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: Java Homework help...JFrame

 
0
  #3
Mar 7th, 2008
Start using proper identifier naming conventions, as published by Sun.
As people are clearly allowed to attack me but I'm not allowed to defend myself, I no longer post to this site.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC