Solved

drawing multiple lines

Posted on 2004-04-13
4
145 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
ID: 10817553
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
ID: 10817582
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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Java JRE greater than 1.6 5 62
MySQL  on Tomcat 8 45
What's wrong with this code? 4 23
How to determine if a string is a valid SHA value 7 33
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
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:

773 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