【发布时间】:2012-11-17 16:35:53
【问题描述】:
我在 JPanel 上画了一条蓝色实线,通过
public void paint(Graphics g) {
Graphics2D g2 = (Graphics2D) g;
super.paint(g2);
if (path.size() >= 2) {
BasisStroke stroke = new BasicStroke(Config.TILE_SIZE_IN_PIXEL / 3, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL);
g2.setStroke(stroke);
g2.setPaint(Color.BLUE);
g2.setPaintMode();
for (int i = 0; i < path.size() - 1; i++) {
g2.drawLine(path.get(i).x, path.get(i).y, path.get(i + 1).x, path.get(i + 1).y);
}
}
}
但我希望这条线是半透明的。我该如何实现?
【问题讨论】:
-
完整的透明线,去掉方法即可;-)。
标签: java jpanel line transparency graphics2d