• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

X and Y coordinates for drawing lines on applet

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have an applet. I am drawing lines on it. The code of my applet is as follows:

I want to make the ending X and Y coordinates of each line as starting X and Y coordinates of the next line. In this way I would be able to draw a continuous line on applet. I am stuck on this issue. Somebody can help me to resolve it. Thanks
 
Bartender
Posts: 3323
86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There are many ways of doing this, probably the easiest and certainly the least elegant is to just set the start coordinates of each line to the appropriate value ie:

A better way would to have an array of single X,Y co-ordinates ie
Then iterate over the array the array length - 1 times using the current index as the start X, Y coordinate and the current index + 1 as the end X, Y coordinate.
 
Anam Zahra
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I tried a lot but unable to find a way to get the solution.
 
Tony Docherty
Bartender
Posts: 3323
86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry but I've no idea what that code is supposed to do or how it relates to your original question. Has your question changed?

I've noticed in both your posts your code has a nested for loop with the inner for loop iterating exactly once. You can remove the inner for loop as it isn't doing anything other than adding confusion.

reply
    Bookmark Topic Watch Topic
  • New Topic