MBC870
MBC870

Reputation: 373

drawLine() using double variables instead of integers

I would like to ask whether it is possible to draw a line using double variables instead of integers. If yes how?

Upvotes: 0

Views: 3186

Answers (2)

Sergii Zagriichuk
Sergii Zagriichuk

Reputation: 5399

Like this ?

             Line2D line = new Line2D.Double();
             Graphics2D g2 = aPaintContext.getGraphics();
             for (double x = bx; x < rightBorder; x += 5) {
                line.setLine(x, by, x, bottomBorder);
                g2.draw(line);

Upvotes: 1

tenorsax
tenorsax

Reputation: 21233

You can use Line2D.Double. Use Graphics2D.draw() to draw it.

See Drawing Geometric Primitives for more details and examples.

Upvotes: 2

Related Questions