Sorry for my ignorance but I having a problem implementing this
solution. I get an error:
this should work and gives you possibility to switch between solid and
dashed border.
I hope this is not your homework.
public class DashBorder extends LineBorder {
public DashBorder(Color c) {
this(c, 1);
}
public DashBorder(Color c, int thickness) {
this(c, thickness, new float[] {5, 5});
}
public DashBorder(Color c, int thickness, float [] dash) {
super(c, thickness);
this.stroke = new BasicStroke(thickness, BasicStroke.CAP_BUTT,
BasicStroke.JOIN_BEVEL, 1, dash, 0);
}
private boolean solid;
private BasicStroke stroke;
public void paintBorder(Component c, Graphics g, int x, int y, int
width, int height) {
if(!solid) {
Graphics2D g2d = (Graphics2D)g.create();
g2d.setStroke(stroke);
super.paintBorder(c, g2d, x, y, width, height);
g2d.dispose();
}
else {
super.paintBorder(c, g, x, y, width, height);
}
}
}
Andrey
--
Andrey Kuznetsov
http://uio.imagero.com Unified I/O for Java
http://reader.imagero.com Java image reader
http://jgui.imagero.com Java GUI components and utilities