Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2011
    Posts
    20
    Rep Power
    0

    Default 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:

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,960
    Rep Power
    8

    Default

    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 - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by stefandanielsen View Post
    what am i doing wrong???:eek::confused:
    • 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

  1. how to draw on Jwindow?
    By aliencc in forum Java 2D
    Replies: 8
    Last Post: 11-13-2010, 04:34 AM
  2. Draw a rhombus
    By jack DANIEL's in forum New To Java
    Replies: 6
    Last Post: 10-13-2010, 07:57 AM
  3. how to draw an arc
    By Baker in forum New To Java
    Replies: 1
    Last Post: 04-16-2009, 09:05 PM
  4. How to Draw Arc in Java
    By Java Tip in forum java.awt
    Replies: 0
    Last Post: 06-23-2008, 11:12 PM
  5. help me draw... please...
    By kureikougaiji in forum New To Java
    Replies: 1
    Last Post: 01-28-2008, 12:22 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •