# An applet using Timer

Moni Patil

Greenhorn

Posts: 9

posted 11 years ago

Code for An applet using Timer that shows a line segment rotating about its mid-point

Moni Patil

Greenhorn

Posts: 9

Ulf Dittmer

Rancher

Posts: 42970

73

posted 11 years ago

That's not a question, it's an assignment. Is it homework that you should be doing? People here are not going to do it for you, although they will help you if you get stuck somewhere along the way.

In the meantime, you could also read up on How to ask questions on JavaRanch, particularly the section on "Do your own homework".

In the meantime, you could also read up on How to ask questions on JavaRanch, particularly the section on "Do your own homework".

Michael Dunn

Ranch Hand

Posts: 4632

posted 11 years ago

see if I can point you in some direction.

think of a square.

each corner of the square has a point location (x,y).

can you draw diagonal lines between these points:

x,y top left to x,y lower right

x,y lower left to x,y top right

can you draw a horizontal line and a vertical line, between the corner x,y positions.

if you can do this, all you have to do is put them in the right order,

add a runnable thread (or timer), and you have your assignment done.

note: the horizontal/vertical lines will be slightly shorter than the diagonals,

so you may have to include an additional calculation if the assignment stipulates

the lines are to be the exact same length.

[ September 16, 2005: Message edited by: Michael Dunn ]

think of a square.

each corner of the square has a point location (x,y).

can you draw diagonal lines between these points:

x,y top left to x,y lower right

x,y lower left to x,y top right

can you draw a horizontal line and a vertical line, between the corner x,y positions.

if you can do this, all you have to do is put them in the right order,

add a runnable thread (or timer), and you have your assignment done.

note: the horizontal/vertical lines will be slightly shorter than the diagonals,

so you may have to include an additional calculation if the assignment stipulates

the lines are to be the exact same length.

[ September 16, 2005: Message edited by: Michael Dunn ]