View Single Post
  #2 (permalink)  
Old 05-31-2007, 05:27 PM
Hasan Hasan is offline
Member
 
Join Date: May 2007
Posts: 11
Hasan is on a distinguished road
You need to call setStroke method of Graphics2D.

Check following example:

Code:
import java.awt.*; import javax.swing.*; public class StrokeExample extends JPanel implements Runnable { protected void paintComponent(Graphics g) { super.paintComponent(g); int w = getWidth(); int h = getHeight(); g.drawLine(0,0,w,h); //default Graphics2D g2 = (Graphics2D) g; g2.setStroke(new BasicStroke(3)); g2.drawLine(0,h,w,0); //thick } public void run() { JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.getContentPane().add(new StrokeExample()); f.setSize(500,400); f.setLocationRelativeTo(null); f.setVisible(true); } public static void main(String[] args) { EventQueue.invokeLater(new StrokeExample()); } }
Reply With Quote