I've written code to draw a rectangle. I'm pretty sure i did everything right. This is my code:
package hmm; import javax.swing.*; import java.awt.*; import java.awt.event.*; public class Hmm { private static class drawrectangle extends JPanel { public void paintComponent(Graphics g) { super.paintComponent(g); g.drawRect(50, 50, 50, 50); } } public static void main(String[] args) { drawrectangle displayPanel = new drawrectangle(); JPanel content = new JPanel(); content.add(displayPanel); JFrame window = new JFrame(); window.setContentPane(content); window.setVisible(true); } }
However whenever i try to run it i get this error:
"java.lang.NoSuchMethodError: main
Exception in thread "main" Java Result: 1"
I'm don't know what this means. Also, I compiled this code using NetBeans IDE.