The detailed API for the <drawPolyline()> method of the <Graphics>
class says, "The figure is not closed if the first point differs from
the last point." So the following program should result in two line
segments being drawn, one from (100,100) to (100,800) and another from
(100,800) to (800,800). However when I execute the program I get the
triangle that would be created by closing the polyline. Isn't that a
bug?
FYI, when I type in "java -version" I get 1.4.2.
---Kevin Simonson
"You'll never get to heaven, or even to LA,
if you don't believe there's a way."
from _Why Not_
####################################################################
import javax.swing.JFrame;
import javax.swing.JPanel;
import java.awt.Graphics;
import java.awt.Color;
import java.awt.Dimension;
public class Bug extends JPanel
{
static final long serialVersionUID = 0L;
private Bug ()
{
setPreferredSize( new Dimension( 900, 900));
setBackground( Color.black);
}
protected void paintComponent ( Graphics page)
{
super.paintComponent( page);
int[] xCoos = { 100, 100, 800 };
int[] yCoos = { 100, 800, 800 };
page.setColor( Color.cyan);
page.drawPolyline( xCoos, yCoos, 3);
}
public static void main ( String[] arguments)
{
Bug bugPanel = new Bug();
JFrame bugFrame = new JFrame( "Bug");
bugFrame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE);
bugFrame.getContentPane().add( bugPanel);
bugFrame.pack();
bugFrame.setVisible( true);
}
}
Patricia Shanahan - 23 Jul 2007 16:39 GMT
> The detailed API for the <drawPolyline()> method of the <Graphics>
> class says, "The figure is not closed if the first point differs from
[quoted text clipped - 5 lines]
>
> FYI, when I type in "java -version" I get 1.4.2.
It works as you expected, two lines rather than a triangle, when I run
it, 1.6.0_01.
Patricia
Roedy Green - 23 Jul 2007 20:17 GMT
>It works as you expected, two lines rather than a triangle, when I run
>it, 1.6.0_01.
ditto for me on 1.6.0_02, Vista Home Premium.

Signature
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
Eric Sosman - 23 Jul 2007 16:49 GMT
kvnsmnsn@hotmail.com wrote On 07/23/07 11:23,:
> The detailed API for the <drawPolyline()> method of the <Graphics>
> class says, "The figure is not closed if the first point differs from
[quoted text clipped - 5 lines]
>
> FYI, when I type in "java -version" I get 1.4.2.
Works fine for me, on two Java versions:
java version "1.4.2_04"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05)
Java HotSpot(TM) Client VM (build 1.4.2_04-b05, mixed mode)
java version "1.6.0"
Java(TM) SE Runtime Environment (build 1.6.0-b105)
Java HotSpot(TM) Client VM (build 1.6.0-b105, mixed mode, sharing)
Solaris 9 (SPARC) -- What's your platform?

Signature
Eric.Sosman@sun.com
Thomas Fritsch - 23 Jul 2007 17:12 GMT
> The detailed API for the <drawPolyline()> method of the <Graphics>
> class says, "The figure is not closed if the first point differs from
[quoted text clipped - 5 lines]
>
> FYI, when I type in "java -version" I get 1.4.2.
When executing your program I got 2 lines, not the triangle.
==> I couldn't reproduce the bug.
(Tested with Java 1.4.2_05, 1.5.0_10, 1.6.0_01, all on WinXP)

Signature
Thomas
HightowerC - 23 Jul 2007 17:18 GMT
2 lines, no triangle for me,
version 1.6.0_02
HightowerC
Patricia Shanahan - 23 Jul 2007 18:17 GMT
> The detailed API for the <drawPolyline()> method of the <Graphics>
> class says, "The figure is not closed if the first point differs from
[quoted text clipped - 3 lines]
> triangle that would be created by closing the polyline. Isn't that a
> bug?
...
Given the general inability to reproduce the problem, how sure are you
that the source code you posted is the test case you ran? Any
possibility that you are running a different version of the program?
Patricia