0

I am having a problem with StdDraw and resizing the window so points appear. I have a Point class with a draw() method

/**
* Draws this point to standard draw.
*/
public void draw() {
    /* DO NOT MODIFY */
    StdDraw.point(x, y);
}

Then in a tester class I have

public static void main(String[] args) {
    Point p = new Point(3, 4);
    StdDraw.setXscale(0, 10);
    StdDraw.setYscale(0, 10);
    p.draw();
}

When I run this, I get two windows that pop up, both with nothing in them. I assume one is a window from the Point class, plotting the point at (3,4) on a coordinate plane that has not been resized, and the other window is the resized window from the tester class with no points on it. Am I missing something here? How can I get this to run in one window without modifying the Point class?

Paul
  • 409
  • 4
  • 12
  • Please read the documentation of StdDraw, then chekcout some examples, tutorials. You can handle that yourself. – Krzysztof Cichocki Aug 10 '17 at 04:46
  • Thank you for the reply. I have read through the documentation, looked at examples, and tutorials. The difference with all of the examples I have seen is that the main method is in the same class as the point being drawn. So if I put my main method in my Point class then yes, I can make it work. But as soon as I make a separate class for main, I get two draw windows popping up. Maybe I've been looking at it for too long and I'm missing something small, but any help would be greatly appreciated. Thank you – Paul Aug 10 '17 at 16:11

1 Answers1

0

OK after a suggestion that I may have two JVM's running, the answer was revealed! The problem was that I had both algs4.jar and stdlib.jar in my classpath variable. I removed algs4.jar from the classpath and it worked. So check your classpath variables if you're running into a similar issue!

Paul
  • 409
  • 4
  • 12