| Author |
java.lang.NoSuchMethodError ??
|
Brian Wieb
Greenhorn
Joined: Apr 14, 2005
Posts: 4
|
|
Hello, I'm using the Head First Java book, chap. 12, page 364. The example program given creates the following error trying to run it. "Exception in thread "main" java.lang.NoSuchMethodError: Main" Does anyone know why I am getting this error? Also any suggestions on where to look for explanations of these types of errors? This is the example program from the book... import java.awt.*; import javax.swing.*; class MyDrawPanel extends JPanel { public void paintComponent(Graphics g) { g.setColor(Color.orange); g.fillRect(20,50,100,100); } } Thanks !
|
 |
Timmy Marks
Ranch Hand
Joined: Dec 01, 2003
Posts: 226
|
|
|
This isn't the whole code is it? You are missing your main method.
|
 |
Brian Wieb
Greenhorn
Joined: Apr 14, 2005
Posts: 4
|
|
OK, I'm new at this...Very new! The book only has the code I listed above. Maybe it's assumed I know what I'm doing? I added a main method listed below, now it runs but produces nothing. I must still be missing something but I don't have a clue what it would be. Any ideas??? import java.awt.*; import javax.swing.*; class MyDrawPanel extends JPanel { public static void main (String[] args) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane(); } public void paintComponent(Graphics g) { g.setColor(Color.orange); g.fillRect(20,50,100,100); } }
|
 |
Timmy Marks
Ranch Hand
Joined: Dec 01, 2003
Posts: 226
|
|
If you are that new to this, I would say what you are missing is chapters 1 through 12 Seriously though, it will be of great benefit to you to understand what is going on before you try this application. You need to know a lot of things before the code you have posted here will work.
|
 |
 |
|
|
subject: java.lang.NoSuchMethodError ??
|
|
|