C
Christopher Benson-Manica
I've read the documentation, and I'm still having trouble
understanding exactly why fillPolygon() doesn't (always) produce a
filled-in version of drawPolygon(). Specifically, I have the
following class:
public class UpIcon implements Icon {
private final Polygon polygon = new Polygon(
new int[]{2,8,5},
new int[]{5,5,2},
3
);
public void paintIcon( Component c, Graphics g, int x, int y ) {
g.drawPolygon( polygon ); // Gives me the shape I want, not filled
// in of course.
g.fillPolygon( polygon ); // Seems to fill the *interior* of the
// shape I get with drawPolygon(), i.e.
// I get a filled polygon that's too
// small.
}
public int getIconWidth() {
return 11;
}
public int getIconHeight() {
return 11;
}
}
Is there something wrong with what I'm doing here, or am I merely
missing some subtlety about how Graphics implements drawPolygon and
fillPolygon? (When the array of yPoints is {5,5,8}, I get a DownIcon
that works the way I want, so I'm presuming the answer is the latter.)
understanding exactly why fillPolygon() doesn't (always) produce a
filled-in version of drawPolygon(). Specifically, I have the
following class:
public class UpIcon implements Icon {
private final Polygon polygon = new Polygon(
new int[]{2,8,5},
new int[]{5,5,2},
3
);
public void paintIcon( Component c, Graphics g, int x, int y ) {
g.drawPolygon( polygon ); // Gives me the shape I want, not filled
// in of course.
g.fillPolygon( polygon ); // Seems to fill the *interior* of the
// shape I get with drawPolygon(), i.e.
// I get a filled polygon that's too
// small.
}
public int getIconWidth() {
return 11;
}
public int getIconHeight() {
return 11;
}
}
Is there something wrong with what I'm doing here, or am I merely
missing some subtlety about how Graphics implements drawPolygon and
fillPolygon? (When the array of yPoints is {5,5,8}, I get a DownIcon
that works the way I want, so I'm presuming the answer is the latter.)