Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: StdDraw Cannot be Resolved??

  1. #1
    Junior Member
    Join Date
    Jan 2012
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default StdDraw Cannot be Resolved??

    I found some code online to draw a pink heart.. sort of a valentine's day heart.. I would like to add to it and customize it some... But I can't get it to work as-is.. I get a compile error that "StdDraw Cannot be resolved" ... Here is the code.. Thanks for any input!!

    import java.awt.color.*;
    import java.awt.Graphics;
    import javax.swing.JPanel;
     
    public class Heart {
        public static void main(String[] args) {
            StdDraw.setXscale(-1.5, +1.5);
            StdDraw.setYscale(-1.5, +1.5);
            StdDraw.setPenColor(StdDraw.PINK);
     
            // draw diamond
            double[] xs = { -1,  0, 1, 0 };
            double[] ys = {  0, -1, 0, 1 };
            StdDraw.filledPolygon(xs, ys);
     
            // circles
            StdDraw.filledCircle(+0.5, 0.5, 1 / Math.sqrt(2));
            StdDraw.filledCircle(-0.5, 0.5, 1 / Math.sqrt(2));
        }
     
    }


  2. #2
    Junior Member
    Join Date
    Dec 2011
    Posts
    6
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Re: StdDraw Cannot be Resolved??

    Hi there!
    I'm pretty sure that the class StdDraw is not in the default java source. You will need to use this code to get it to work StdDraw.java

  3. #3
    Junior Member
    Join Date
    Jan 2012
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: StdDraw Cannot be Resolved??

    Quote Originally Posted by er1111 View Post
    Hi there!
    I'm pretty sure that the class StdDraw is not in the default java source. You will need to use this code to get it to work StdDraw.java
    Holy crow!! Is there an easier way to do this ? I'm just trying to draw a heart... lol... can this be similar to drawing a smiley face? I can do that!!

  4. #4
    Junior Member
    Join Date
    Jun 2014
    Posts
    19
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: StdDraw Cannot be Resolved??

    You are getting StdDraw cannot be resolved because the StdDraw class has to be in the same package as this class

  5. #5
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: StdDraw Cannot be Resolved??

    This thread is over 2 years old. The OP has probably solved it by now.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. [SOLVED] This absolute uri (http://displaytag.sf.net) cannot be resolved in either web.xml or
    By santosh.dhulipala in forum JavaServer Pages: JSP & JSTL
    Replies: 3
    Last Post: October 4th, 2021, 09:58 AM
  2. mp3 file cant be resolved
    By aNGaJe in forum What's Wrong With My Code?
    Replies: 3
    Last Post: February 2nd, 2012, 07:20 AM
  3. Highlighted words Not resolved
    By Rajiv in forum What's Wrong With My Code?
    Replies: 2
    Last Post: August 4th, 2011, 07:28 AM
  4. cannot be resolved to a type
    By Teraphim in forum What's Wrong With My Code?
    Replies: 1
    Last Post: February 16th, 2010, 10:42 AM
  5. Error msg : 'pageContext' cannot be resolved in tag file....
    By saikrishna436 in forum JavaServer Pages: JSP & JSTL
    Replies: 5
    Last Post: September 8th, 2009, 07:58 AM