Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to draw straight line instead of curved line??

 
Michelle Wang
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear friends:
I have following code, which can draw curved lines when mouse moves, but if I only hope to draw stright line, not curved one, How to draw straight line instead of curved line??

If can help advice something, thanks in advance.
Regards

 
Craig Wood
Ranch Hand
Pie
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
pressMouse -> start line
releaseMouse -> end line
 
Michelle Wang
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Excellent!! Thanks so much!!Super!!
[ June 21, 2007: Message edited by: girl sunny ]
 
Michelle Wang
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have another idea after your wonderful code,
I tried but failed with following code, If I hope to apply your draw method in your reply post to the following code, is it possible or not, last night I tried hours, no success.

 
Craig Wood
Ranch Hand
Pie
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Edit:
Changed this line in ComponentMover.addLine

to this

to prevent the member variable firstLoc from changing values passed to previously
created instances of LineStore.
Also, replaced all loop count variables with letter j.
[ June 22, 2007: Message edited by: Craig Wood ]
 
Michelle Wang
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Great! Thanks a lot!!
 
justin joel
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to create a simple paint application?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic