Solved

drawing multiple lines

Posted on 2004-04-13
4
143 Views
Last Modified: 2010-03-31
hi,
i'm trying to draw lines at different locations. what i want is assistance on whther i should use a loop to do that. the x,y coordinates will be randomly picked. any sites or codes that might assist would be greatly appreciated
0
Comment
Question by:Kalliba
4 Comments
 
LVL 92

Accepted Solution

by:
objects earned 20 total points
Comment Utility
yes use a loop

for (int i=0; i<100; i++)
{
   int x1 = ...;
   int y1 = ...;
   int x2 = ...;
   int y2 = ...;
   g.drawLine(x1, y1, x2, y2);
}
0
 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
You could try something like:

final int DELTA_X = 20;
int numLines = 5;
int height = getHeight();
for(int i = 0;i < numLines;i++) {
      int x = 0;
      int y = (int)(Math.random() * height);
      g.drawLine(x, y, x + deltaX, y);
}
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
hash value 2 38
countAbc challenge 9 49
Systems talking to each other 5 107
Java / Linux and Regular Expressions 11 43
For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now