suspected bug in my java interpreter

K

kvnsmnsn

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);
}
}
 
P

Patricia Shanahan

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.

It works as you expected, two lines rather than a triangle, when I run
it, 1.6.0_01.

Patricia
 
E

Eric Sosman

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.

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?
 
T

Thomas Fritsch

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.
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)
 
P

Patricia Shanahan

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?
....

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,170
Latest member
Andrew1609
Top