我的问题是我想在一个面板中画一条虚线。我已经能够做到了,但它也把我的边框画成了虚线。
有人可以解释一下为什么吗?我正在使用paintComponent进行绘制并直接绘制到面板上。
这是绘制虚线的代码:
public void drawDashedLine(Graphics g, int x1, int y1, int x2, int y2){
Graphics2D g2d = (Graphics2D) g;
//float dash[] = {10.0f};
Stroke dashed = new BasicStroke(3, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[]{9}, 0);
g2d.setStroke(dashed);
g2d.drawLine(x1, y1, x2, y2);
}