Yes, you should do it in Graphics2D, but this is hardly a problem, since every graphic in Swing is a Graphics2D object (it just keeps the old interface for compatibility reasons).
public void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2 = (Graphics2D) g; g2.setStroke(new BasicStroke(3)); g2.drawLine(...);
As you can see, g2.setStroke (...) allows you to change the course and even BasicStroke, which provides an easy choice of line width.
Edwin buck
source share