Is it possible to draw a polygon or a line more than 1 pixel wide?
Ans : JDK 1.1 doesn’t have support for this. The standard workaround for drawing a thick line is to draw a filled polygon. The standard workaround for drawing a thick polygon is to draw several polygons. There is a useful class at http://www.apl.jhu.edu/~hall/java/GraphicsUtil.html which extends the drawxxx and fillxxx methods of java.awt.Graphics. It adds a Line Width argument to most of the drawxxx methods, a Color argument to most of the drawxxx and fillxxx methods, and a Font argument to drawString and drawChars. JDK 1.2 introduces the java.awt.BasicStroke class. You set the stroke on a Graphics object, and line rendering is done using that info. BasicStroke bs = new BasicStroke(width, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 1.0f, null, 0.0f); g.setStroke(bs); g.drawLine( …
Related Questions
- I want to give students with specific learning needs as much assistance as possible, but where do I draw the line on ensuring that students take advantage of available help and accommodations?
- Is it possible to select two atoms, draw a dotted line between them, but don display the distance?
- Is it possible to draw a polygon or a line more than 1 pixel wide?