[英]How do I draw a dotted line from the paint method on a JComponent?
I have to draw a dotted or dashed line In a JComponent. 我必须在JComponent中绘制虚线。 How do I do that?
我怎么做?
Get a hold of a Graphics2D
, and use its setStroke()
method to set a suitable stroke. 握住
Graphics2D
,并使用其setStroke()
方法设置合适的笔触。 It should be enough with a BasicStroke
to get a dotted line, nothing fancy. BasicStroke
应该足以得到虚线,没有花哨的地方。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.