I am in the process of writing a code that involves buttons and a displaypanel and a lot of different things, so ive decided to Test as I go with every aspect of the code. I tried setting up just the background display with a line and two rectangles and i got errors. here is my code:
import java.awt.*; import javax.swing.*; public class SaucerPanel extends JPanel{ static final long serialVersionUID = 1; public SaucerPanel(){ setPreferredSize(new Dimension(500,400)); setBackground(Color.red); } public void paintComponent(Graphics g){ super.paintComponent(g); g.drawLine(0,380,500,380); g.drawRect(111,180,200,100); g.drawString("hovering...", 10, 15); } }
and it compiled just fine but when i hit Run on Dr. Java I got this under the Interactions Panel
java.lang.NoSuchMethodError: main
at sun.reflect.NativeConstructorAccessorImpl.newInsta nce0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInsta nce(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newI nstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at edu.rice.cs.dynamicjava.symbol.JavaClass$JavaConst ructor.evaluate(JavaClass.java:298)
at edu.rice.cs.dynamicjava.interpreter.ExpressionEval uator.handleConstructor(ExpressionEvaluator.java:1 28)
at edu.rice.cs.dynamicjava.interpreter.ExpressionEval uator.visit(ExpressionEvaluator.java:98)
at koala.dynamicjava.tree.SimpleAllocation.acceptVisi tor(SimpleAllocation.java:137)
at edu.rice.cs.dynamicjava.interpreter.ExpressionEval uator.value(ExpressionEvaluator.java:38)
can anyone explain/help me with this