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