I just wanted to know how to draw a thick line and also can anyone tell how drawArc works , in know how to make it work (x,y,width,height,startAngle,Arcangle) but i cant figure it out. Line just arc in ways i dont really understand. Thanks.

Recommended Answers

All 2 Replies

Also can anyone tell me how to use delay function to waste time. I have 3 square thatr flash on and off endless amount of times but they go way to fast.

Run this code below. See the comments for an explanation. This should help understand what you need to use.

import javax.swing.*;
import java.awt.*;

class TestPanel extends JPanel
{
	//paint function
	public void paint(Graphics g)
	{
		//cast to Graphics2D
		Graphics2D g2D = (Graphics2D)(g);
		
		//set stroke
		int lineWidth = 5;
		g2D.setStroke( new BasicStroke(lineWidth));
		
		//draw line
		g2D.drawLine(0,0, 100, 100);
		
		//draw an arc from 45 degrees to (45+90) degrees. 90 determines how wide the arc is
		g2D.drawArc(0,0, 100, 100, 45, 90);
	}
	
}

class Test
{
	public static void main(String[] a)
	{
		//create JFrame
		JFrame j = new JFrame();	
		
		//add TestPanel
		j.getContentPane().add( new TestPanel());
		
		//show JFrame
		j.setBounds(0,0, 100,100);
		j.setVisible(true);
	}	
}

:?: For more help, www.NeedProgrammingHelp.com

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.