0

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.

2
Contributors
2
Replies
3
Views
11 Years
Discussion Span
Last Post by NPH
0

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.

0

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.