?
Solved

drawing multiple lines

Posted on 2004-04-13
4
Medium Priority
?
157 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 92

Accepted Solution

by:
objects earned 80 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

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…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
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 theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses
Course of the Month10 days, 21 hours left to enroll

770 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