Results 1 to 3 of 3
Thread: why cant i draw this box???
- 05-12-2011, 03:31 PM #1
Member
- Join Date
- Mar 2011
- Posts
- 20
- Rep Power
- 0
why cant i draw this box???
hey hey ... im having a small problem with my new program... it wont let me draw a box in eclipse. can anybody help me :
import java.awt.*;
public class DrawLine {
public static void main(String[] args) {
DrawingPanel panel = new DrawingPanel(200, 100);
Graphics g = panel.getGraphics();
g.drawLine(25, 75, 175, 25);
}
}
the error says : DrawingPanel cannot be resolved to a type
what am i doing wrong???:eek::confused:
- 05-12-2011, 03:34 PM #2
Well, where did you define DrawingPanel?
Besides that, you're doing your painting horribly wrong. If you're calling getGraphics() on a component, you're doing something wrong. Instead, extend JPanel, override its paintComponent() method, and do your painting in that.How to Ask Questions the Smart Way
Static Void Games - GameDev tutorials, free Java and JavaScript hosting!
Static Void Games forum - Come say hello!
-
- You're using graphics incorrectly as mentioned above. The tutorials will show you how to do drawing correctly, or if you have more problems, then post more of your code here.
- You're not giving us the complete error message so we have to guess what it actually states
- You're not using code tags when posting code but instead bolding your code making it hard to read. Please see the link in my signature on how to use code tags.
Similar Threads
-
how to draw on Jwindow?
By aliencc in forum Java 2DReplies: 8Last Post: 11-13-2010, 05:34 AM -
Draw a rhombus
By jack DANIEL's in forum New To JavaReplies: 6Last Post: 10-13-2010, 08:57 AM -
how to draw an arc
By Baker in forum New To JavaReplies: 1Last Post: 04-16-2009, 10:05 PM -
How to Draw Arc in Java
By Java Tip in forum java.awtReplies: 0Last Post: 06-24-2008, 12:12 AM -
help me draw... please...
By kureikougaiji in forum New To JavaReplies: 1Last Post: 01-28-2008, 01:22 PM
Bookmarks