This week's book giveaway is in the Java in General forum.
We're giving away four copies of Think Java: How to Think Like a Computer Scientist and have Allen B. Downey & Chris Mayfield on-line!
See this thread for details.
Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

GUI problem for a really beginner...error?!

 
Nadine Ernest
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, i just wrote this code and it compiles but it just doesnt give me anything....when i click the run button on Jcreator it tells me
java.lang.NoSuchMethodError: main
Exception in thread "main"
Process completed.


and this is my code:





What is the problem???!!!
why it doesnt run?!?!!

thanks a lot!
 
Maneesh Godbole
Saloon Keeper
Posts: 11027
12
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you forgotten



 
Campbell Ritchie
Sheriff
Posts: 48921
58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, she has forgotten it. I got it to work, but I am not sure I want code telling me I am called Nadine It runs, but won't appear and won't close. You need code to make it visible (setVisible) and to set its default close operation. You can find more about that in the JFrame class. The strange contents of the main method are explained here. I know your lecturer won't believe you, but that is the correct way to start off a Swing app.

As I told you earlier, the getContentPane() calls are all unnecessary. Just write add() or setLayout(). You don't need to set BorderLayout on a JFrame; it defaults to BorderLayout. You can forget about setTitle if you pass the title to the constructor: super("Nadine's Frame");
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic