在Window Mobile 和Java ME中画线只支持线宽为1,引路蜂二维图形库允许指定Pen的宽度。
下例显示了多条不同宽度的线段。
private void Lines() { Color greenColor = new Color(0x00ff00,false); //Clear the canvas with white color. graphics2D.Clear(Color.White); Pen pen = new Pen(greenColor, 1); graphics2D.DrawLine(pen, 20, 150, 60, 50); pen = new Pen(greenColor, 2); graphics2D.DrawLine(pen, 40, 150, 80, 50); pen = new Pen(greenColor, 3); graphics2D.DrawLine(pen, 60, 150, 100, 50); pen = new Pen(greenColor, 5); graphics2D.DrawLine(pen, 80, 150, 120, 50); pen = new Pen(greenColor, 7); graphics2D.DrawLine(pen, 100, 150, 140, 50); pen = new Pen(greenColor, 10); graphics2D.DrawLine(pen, 120, 150, 160, 50); }