日期:2014-05-20  浏览次数:20664 次

如何设置画笔的宽度?想画一条宽一点的线段怎么实现
如何设置画笔的宽度?想画一条宽一点的线段怎么实现

------解决方案--------------------
用BasicStroke
------解决方案--------------------
Graphics2D g2D = (Graphics2D) g;
g2D.setStroke(new BasicStroke(5.0f)); //5.0即线的宽度
ged.draw(...);
------解决方案--------------------
void paintComponent(Graphics g)
{
super.paintComponent(g);
Graphics2D g2d = (Graphics2D) g;
g2d.setStroke(new BasicStroke(5.0f)); //边界宽度为5
g2d.drawLine(0,0,10,10);
}