Originally posted by Ernest Friedman-Hill:
For some reason, continued with a slightly reworded repost here.
Originally posted by John Smith:
The third and fourth arguments in Rectangle2D.Double() are width and height, respectively. With that in mind, to show the bars horizontally, your code would look something like this:
Originally posted by John Smith:
I ran your code, and it displays the bars vertically, as you want. Are you sure that's the code that you are actually running?
Originally posted by John Smith:
Because of the integer division, your degreeIncrement variable will always be equal to zero. Subsequently, the arcs you are trying to draw all have angle 0 and that's why you don't see them. The fix is to divide by a float and cast the result to an integer.
Additionally, the line startAngle += degreeIncrement; should be inside the for loop.
Originally posted by John Smith:
Because of the integer division, your degreeIncrement variable will always be equal to zero. Subsequently, the arcs you are trying to draw all have angle 0 and that's why you don't see them. The fix is to divide by a float and cast the result to an integer.
Additionally, the line startAngle += degreeIncrement; should be inside the for loop.
Originally posted by Timmy Marks:
Sorry if I wasn't clear, the grow field and the radius should be members of the individual classes, and the changeSize() method is a method of the Shape class, overridden in the subclasses. Actually, the name radius is maybe misleading, since it is more associated with circles, and not with squares.
Since they are both growing at the same time, start one of them with grow = true and the other with grow = false!
Originally posted by Timmy Marks:
Actually, only one (or none) of the two operations grow() or shrink() actually changes anything (What happens if size == 50?). Maybe a single method would be better: a boolean saying whether it grows or shrinks
P.S. Would someone edit the original post to fix the code tags??? On my monitor it's like 200 inches wide!
[ June 14, 2005: Message edited by: Timmy Marks ]
Originally posted by Ernest Friedman-Hill:
That looks great -- except that you're calling both grow() and shrink() on each shape, so that the net effect is... nothing! You want to just grow the circle, and shrink the square, right?
Originally posted by Ernest Friedman-Hill:
Here's what I would do:
1) Give Shape a shrink(int pixels) method and a grow(int pixels) method. These methods have to change the member variable that controls the size of the shape.
2) In actionPerformed(), call the appropriate methods on the appropriate objects, then call repaint().