The Artima Developer Community
Sponsored Link

Java Answers Forum
java.awt.Graphics

5 replies on 1 page. Most recent reply: Oct 26, 2006 11:40 PM by Z L

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 5 replies on 1 page
Nancy

Posts: 11
Nickname: ac121107
Registered: Feb, 2004

java.awt.Graphics Posted: Mar 16, 2004 6:07 AM
Reply to this message Reply
Advertisement
Is there something like g.drawline to draw a dash line?
Thanks
Nancy


Viswanatha Basavalingappa

Posts: 84
Nickname: viswagb
Registered: Nov, 2003

Re: java.awt.Graphics Posted: Mar 16, 2004 7:37 AM
Reply to this message Reply
Hi

java.lang.Object
|
+---java.awt.Component
|
+---java.awt.Canvas
|
+---Curveline

go to this class and method drawBigPointDottedLine ()

here is ..
public void drawBigPointDottedLine(Graphics tempGraphics,
int x1,
int y1,
int x2,
int y2,
int numOfDots)

This routine draws a dotted line between two points, using a large dot.

I hope this helps you..
Viswa
---------

Viswanatha Basavalingappa

Posts: 84
Nickname: viswagb
Registered: Nov, 2003

Re: java.awt.Graphics Posted: Mar 16, 2004 7:42 AM
Reply to this message Reply
SOrry, the early reply I gfave was 3rd party API, if you are uding JDK 1.2 then see bellow code it will help you...

Use Java2D, setting a stroke to the graphics:
Graphics2d g2 = (Graphics2d)g;
float dash1[] = {3.5f};
roundStroke = new BasicStroke(1.5f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10f, dash1, 0.0f);
g2.setStroke(roundStroke);
 
[\java]
 
Viswa
'-------

Viswanatha Basavalingappa

Posts: 84
Nickname: viswagb
Registered: Nov, 2003

Re: java.awt.Graphics Posted: Mar 16, 2004 7:43 AM
Reply to this message Reply
Hi,

Sorry, the early reply I gfave was 3rd party API, if you are uding JDK 1.2 then see bellow code it will help you...

Use Java2D, setting a stroke to the graphics:

Graphics2d g2 = (Graphics2d)g;
float dash1[] = {3.5f};
roundStroke = new BasicStroke(1.5f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10f, dash1, 0.0f);
g2.setStroke(roundStroke);


Viswa
-------

Nancy

Posts: 11
Nickname: ac121107
Registered: Feb, 2004

Re: java.awt.Graphics Posted: Mar 16, 2004 8:33 AM
Reply to this message Reply
Thanks for your help
Nancy

Z L

Posts: 2
Nickname: vitamin
Registered: Oct, 2006

Dashed Line suddenly became Solid Line! Posted: Oct 26, 2006 11:40 PM
Reply to this message Reply
Hi,

Can anyone help me with a problem that I'm facing now?

I managed to draw a dashed line between two rotating objects. However, I noticed that at certain rotating angle, the dashed line become a solid line!

Below is my code:

Graphics2D g2d = (Graphics2D)g;
Line2D line = new Line2D.Double(x1, y1, x2, y2);
float[] dashPattern = {8,18};
g2d.setStroke(new BasicStroke(1.0F, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 1.0F, dashPattern, 0));
g2d.draw(line);

Thank you.

Flat View: This topic has 5 replies on 1 page
Topic: getwidth() function in a tree datastructure Previous Topic   Next Topic Topic: Bad File Descriptor error

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use