Drawing dotted lines

Hey
I've already figured out how to draw dotted lines so that's not the questions
the thing is I only need to draw some lines as dotted, some as dashed and all others just normal..
I figured I could make radiobox to select which line.. then I save that to an array of some sort and then in the paintComponent thing I should make an if to check for array value and change the stoke according to that
so far I've just made my lines dotted like this
http://www.jguru.com/faq/view.jsp?EID=114099
but now everything is dotted.. even the borders around my buttons..
ni my applet I have some buttons which are connected with a line.. I want that line dotted or dashed when the users wants it to.. and only then otherwise just normal lines
I couldn't find anything about that on the google =(

done!
now I want to be able to use diffrent line style combinations but it doesn't work
currently it only uses the linestyle that you selected for the first line and then uses that for every line after that too
this is my code
     public void paintComponent(Graphics g) {
          super.paintComponent(g);
          Graphics2D g2d = (Graphics2D)g;
          g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
          g2d.setColor(lijnKleur);
          for (int i = 0; i < Main.XList.size(); i++) {
               int j = (i - 1);
               int k = (i + 1);
               int aantal = 0;
               if ((k % 2 == 0) && (i != 0)) {
                    if (Main.lijnstyleList.get(aantal) == 1){
                         g2d.setStroke(normaal);
                    else if (Main.lijnstyleList.get(aantal) == 2){
                         g2d.setStroke(gestippeld);
                    else if (Main.lijnstyleList.get(aantal) == 3){
                         g2d.setStroke(gestreept);
                    else{
                         g2d.setStroke(normaal);
                    int tmpX_oud = Main.XList.get(j) + (Main.breedte / 2);
                    int tmpY_oud = Main.YList.get(j) + (Main.hoogte / 2);
                    int tmpX = Main.XList.get(i) + (Main.breedte / 2);
                    int tmpY = Main.YList.get(i) + (Main.hoogte / 2);
                    aantal++;
                    if (tmpY_oud > tmpY){
                         tmpY = tmpY + (Main.hoogte / 2);
                         int half = tmpY + (Main.spacing / 2);
                         if ((tmpY_oud != tmpY) && (tmpX_oud != tmpX)) {
                              g2d.drawLine(tmpX_oud, tmpY_oud, tmpX_oud, half);
                              g2d.drawLine(tmpX_oud, half, tmpX, half);
                              g2d.drawLine(tmpX, half, tmpX, tmpY);
                         else{
                              g2d.drawLine(tmpX_oud, tmpY_oud, tmpX, tmpY);
                         g2d.drawLine(tmpX, tmpY, tmpX - 5, tmpY + 8);
                         g2d.drawLine(tmpX, tmpY, tmpX + 5, tmpY + 8);
                    else if (tmpY_oud < tmpY){
                         tmpY = tmpY - (Main.hoogte / 2);
                         int half = tmpY - (Main.spacing / 2);
                         if ((tmpY_oud != tmpY) && (tmpX_oud != tmpX)) {
                              g2d.drawLine(tmpX_oud, tmpY_oud, tmpX_oud, half);
                              g2d.drawLine(tmpX_oud, half, tmpX, half);
                              g2d.drawLine(tmpX, half, tmpX, tmpY);     
                         else{
                              g2d.drawLine(tmpX_oud, tmpY_oud, tmpX, tmpY);
                         g2d.drawLine(tmpX, tmpY, tmpX - 5, tmpY - 8);
                         g2d.drawLine(tmpX, tmpY, tmpX + 5, tmpY - 8);
                    else {
                         if (tmpX_oud > tmpX){
                              tmpX = tmpX + (Main.breedte / 2);
                              g2d.drawLine(tmpX_oud, tmpY_oud, tmpX, tmpY);
                              g2d.drawLine(tmpX, tmpY, tmpX + 8, tmpY - 5);
                              g2d.drawLine(tmpX, tmpY, tmpX + 8, tmpY + 5);
                         else{
                              tmpX = tmpX - (Main.breedte / 2);
                              g2d.drawLine(tmpX_oud, tmpY_oud, tmpX, tmpY);
                              g2d.drawLine(tmpX, tmpY, tmpX - 8, tmpY - 5);
                              g2d.drawLine(tmpX, tmpY, tmpX - 8, tmpY + 5);
          g2d.setStroke(normaal);
     }**EDIT**
according to this it can be done..
http://java.sun.com/developer/JDCTechTips/2003/tt0520.htm
no clue why mine doesn't work then
Edited by: Nizzle on Sep 13, 2007 10:15 AM

Similar Messages

  • Drawing dashed line or dotted line in a flex line chart

    Friends,
    I want to draw a line chart which should be either dotted or dashed.
    since there is no component like dashed line chart, can anyone help me in creating one.
    i think if i extend the line series component, then i can draw that.
    but am stuck there. pls help people.
    Regards,
    Anoop

    Try looking [url http://www.macdevcenter.com/pub/a/mac/2002/03/22/vertical_text.html]here.
    : jay

  • When using the Pencil, I need to be able to draw an organic dotted line, but there is a shortcut in place that connects the dots because I'm double clicking. How do I get rid of this shortcut?

    When using the Pencil, I need to be able to draw an organic dotted line, but there is a shortcut in place that connects the dots because I'm double clicking. How do I get rid of this shortcut?

    What is the purpose of the double click?  If you click once to deposit each mark in sequence the dots should not join. However, if you click once to create the first mark, then hold down the Shift key, each subsequent mark with the Shift key held down will join the dots and create a line.

  • How to draw a straight  dotted line on Bar chart at 70%?

    Hi
    Could you please let me know how to draw a straight dotted line on BAR CHART at 70%?
    Thank you

    Hi,
    This may vary depending on what version of crystal you are using.
    Right click on the graph & go to 'chart options' & choose 'Grids'
    In the grids pane go to the grids tab.  From there check the 'draw custom line at' and specify where you want to draw the custom line.
    Once the line is drawn highlight the line, right click and go to 'chart options' & 'selected item'.
    select what format you want the line to look like (choose the dashed one).
    good luck!

  • Draw a dotted line

    Hello! Is it possible to draw a dotted line in PSE 8 Mac? If so, can I choose the thickness of the line and the space between the lines?
    Thanks,

    I don't know of an action that  will do it, but a manual configuration is easy.
    In Editor, go to Edit>Preferences>Guide and Grids, and configure the grid to your specs. Go to View>Grid -check that,  and also Snap to grid
    Access the line tool under the shape selection tool. At the top you can enter the weight in pixels (thickness). Hold down the shift key as you drag out the line.
    The grid is your guide. Interruptions of the line require manual input.

  • I am trying to draw a dotted line around a image through phtoshop CS5 sdk(64 bit)

    the problem is that the dotted line is being created on my computer but it is not working on other computer ... when i checked on other system , it showed a error code on Play command .. i have windows 7 ( 64 bit )  and other system was also 64 bit ..
    i have tried most of the things i know but the problem still persists. now i rely on you guys to get some advice and help ..
    please help me
    please send me code if you could create it
    . thank you

    I see this error in your output:
    2014-11-26 10:55:23,583 ERROR [ThemeAutoDeployer]
    java.io.FileNotFoundException: /tmp/liferay/com/liferay/portal/deploy/dependencies/liferay-theme.tld (Too many open files)
    I'm not across what the EBS recommended setting for this is, or if there is one.  But try running:
    ulimit -n
    ... and if the number is low, edit /etc/security/limits.conf , add some entries for increased "soft nofile" and "hard nofile" and run sysctl -p.  See Linux & Java tips: Too many open files .

  • Dashed or dotted line

    How can I draw a line that is dashed or dotted in word document? I know how to use the tools window, but how do I make the line dashed or dotted?
    intel iMac   Mac OS X (10.4.6)  

    Special case: Dotted line fill to a Tab postion.
    You can use a dotted or dashed lin to fill the space from the end of a line of text to a tab position by formatting the tab stop.
    Easier to demonstrate than explain:
    Open a New WP Document.
    Set a Left tab at the 5 inch mark.
    Double click the tab marker to open the tab fomat dialogue.
    Click one of the three non-highlighted 'fill' buttons.
    Click OK to accept the setting and close the dialogue.
    Press tab.
    A line of the fill character should be inserted from the left margin (ie the end of the line of text) to the tab position.
    Text added to the beginning of the line (ei. before the tab stop) will replace the fill characters it covers. Text added after the tab stop will be appended to the end of the line of fill characters.
    Regards,
    Barry

  • Creating a 'dotted line' from a 'solid line'?

    In Pages one can draw a line, and then choose to have it solid, or dotted, or a series-of-strokes (with a click). Is there anything comparable in Motion? I'd love to be able to turn my solid line into a 'dotted line' or 'series-of-strokes' with a single click.

    http://www.motionsmarts.com/tutorials/drawinglines/drawinglines1.html
    bogiesan

  • Draw a Line From any Point A To any Point B Dynamically Using AS3

    I am trying to make an anmation where there are several locations(say A,B,C,D,......) made on a  map. If a person clicks on one location A and then another location B, I wanted to draw a dotted line from point A (from  destination of the plane) to point B(to destination of the plane)  using AS3. Please help me........

    Here is a quick and dirty timeline code that does it (class is below):
    var line:Shape;
    var lineGraphics:Graphics;
    var clickSwitch:int = 0;
    var mousePositions:Array = [];
    var conversion:Number = 180 / Math.PI;
    init();
    function init():void {
         drawBackground();
         line = new Shape();
         addChild(line);
         lineGraphics = line.graphics;
         stage.addEventListener(MouseEvent.CLICK, onClick);
    function onClick(e:MouseEvent):void
         clickSwitch = 1 - clickSwitch;
         mousePositions[clickSwitch] = new Point(mouseX, mouseY);
         if (clickSwitch == 0) {
              drawLine();
         else {
              removeLine();
    function removeLine():void
         lineGraphics.clear();
         line.rotation = 0;
    function drawLine():void
         lineGraphics.lineStyle(1, 0xff0000);
         lineGraphics.moveTo(0, 0);
         var dotDistance:Number = 2;
         var nextX:Number = dotDistance;
         while (line.width < Point.distance(mousePositions[0], mousePositions[1])) {
              lineGraphics.lineTo(nextX, 0);
              nextX += dotDistance;
              lineGraphics.moveTo(nextX, 0);
              nextX += dotDistance;
         line.rotation =  conversion * Math.atan2(mousePositions[0].y - mousePositions[1].y, mousePositions[0].x - mousePositions[1].x);
         line.x = mousePositions[1].x;
         line.y = mousePositions[1].y;
    function drawBackground():void
         var s:Shape = new Shape();
         var g:Graphics = s.graphics;
         g.beginFill(0xC0C0C0);
         g.drawRect(0, 0, stage.stageWidth, stage.stageHeight);
         g.endFill();
         addChild(s);
    Class:
    package
         import flash.display.Graphics;
         import flash.display.Shape;
         import flash.display.Sprite;
         import flash.events.MouseEvent;
         import flash.geom.Point;
         public class DottedLine extends Sprite
              private var line:Shape;
              private var lineGraphics:Graphics;
              private var clickSwitch:int = 0;
              private var mousePositions:Array = [];
              private var conversion:Number = 180 / Math.PI;
              public function DottedLine()
                   init();
              private function init():void {
                   drawBackground();
                   line = new Shape();
                   addChild(line);
                   lineGraphics = line.graphics;
                   stage.addEventListener(MouseEvent.CLICK, onClick);
              private function onClick(e:MouseEvent):void
                   clickSwitch = 1 - clickSwitch;
                   mousePositions[clickSwitch] = new Point(mouseX, mouseY);
                   if (clickSwitch == 0) drawLine();
                   else removeLine();
              private function removeLine():void
                   lineGraphics.clear();
                   line.rotation = 0;
              private function drawLine():void
                   lineGraphics.lineStyle(1, 0xff0000);
                   lineGraphics.moveTo(0, 0);
                   var dotDistance:Number = 2;
                   var nextX:Number = dotDistance;
                   while (line.width < Point.distance(mousePositions[0], mousePositions[1])) {
                        lineGraphics.lineTo(nextX, 0);
                        nextX += dotDistance;
                        lineGraphics.moveTo(nextX, 0);
                        nextX += dotDistance;
                   line.rotation =  conversion * Math.atan2(mousePositions[0].y - mousePositions[1].y, mousePositions[0].x - mousePositions[1].x);
                   line.x = mousePositions[1].x;
                   line.y = mousePositions[1].y;
              private function drawBackground():void
                   var s:Shape = new Shape();
                   var g:Graphics = s.graphics;
                   g.beginFill(0xC0C0C0);
                   g.drawRect(0, 0, stage.stageWidth, stage.stageHeight);
                   g.endFill();
                   addChild(s);

  • Dashed/Dotted Line instead of underlined Text

    Hi All,
    I am trying to build a component in which I need to show dashed or dotted line instead of underline for <mx:Text/> control.
    Say if I have underlined text in various places in a <mx:Text/> I want the that text should be underlined with a dashed/dotted line but not complete solid line.
    How can I acheive this...? Anyone having any ideas on this ...?
    Thanks in advance,
    Bhasker Chari

    Hi GordonSmith,
    Thank you very much for replying...I also had this thought in mind but it would be very difficult it seems because inorder to find the coordinates of each character where the underline is there and push the coordinates into an Array by traversing the whole text and after that we need to draw the lines onto th e UI using the drawing API.
    And one more thing I have observed is using the drawing API(by drawing using sprite) we need to add the sprite to the stage so we need to draw for each and every  underlined character using sprite and we need to add it to the stage.
    Say if the <mx:Text /> control is in a canvas container then we need to add sprite instance drawing dotted underline for each word and add it to the Canvas container...but this will make the positioning of the dotted line very difficult.
    Hope this makes sense....
    Thanks in advance,
    Bhasker Chari

  • Smartform : Require a dotted line for a window

    Hi,
    Can you please provide a way to have a dotted line for a window in Smart forms.
    I have used the ‘Template’ options ‘Dashed Lines’ (of the Tab ‘Grid’), but not successful.
    Regards,
    Karuna Reddy

    Hi Karuna,
       I dont think it is possible to draw a dotted line dynamically for a window. Whereas you can do one thing, in a text element draw underscore's(_) or dots(.) but this should be the last to be displayed in the window. Make sure the window width is for the full width of the page or else you wont get the dotted line for the full width of the page.
    Reward if helpful.
    Regards,
    Tushar

  • Simple dotted line?

    I have stroke chosen. I have dotted chosen, this is in CS4.  I chose rounded caps.  I chose 1 pt stroke and 1 pt gap with stroke 1 pt.  I use the pen tool or the line segment tool and draw it.  No dotted line.  I try selecting it.  I only get a regular line.  I really can't figure it out.  The line segment or pen tool doesn't see the setting.  Why does it have dash gap dash gap dash gap 3 times?  So you can change the pattern.  I only want...........................  just like that.
    thanks,  when I have the stroke selected as dashed why doesn't my pen tool do it?

    First you go to the appearance panel and there is a fly out menu from the upper right make sure that New Art Has Basic Appearance is unchecked.
    Then the first thing you should understand is that one point is very fine and at fit to screen magnification you might not see the dotted line with the specs you have stated.
    Then to understand how to make dot with the dash option might not sound at first logical to you but it actually is logical.
    You choose the round end cap as you did but you only need to end caps to make a dot so you simply give it a dash of "0".
    That means you have to give more than 1 pt gap and the round end points extend beyond the end point of each dash a .5 pt on each side leaving no real gap so the setting has to be 2 pt.
    If you gave it a stroke of two then the end caps are still "0" but the gap is 4pt.
    http://mysite.verizon.net/wzphoto/Dotted.mov
    We cross posted i think it is because the line is to thin for OP to notice that it is dotted.

  • How to make a curve dotted line

    Hi there,
    Since now 2 days I am trying to figure out how to make a curve dotted line with photoshop CS3 on WinXP. I know how to make a strait line using the line tool.
    Now, how to make a curve line ? I tried the pen tool, but it ended up with a filled shape rather than with a curve line
    How to set the thickness of this curve ?
    How to make a dotted curve ?
    Of course, I don't want to use hand-drawings with the brush.
    Thanks a lot for your help,
    Alex_pier

    Used the Pen tool, but click on the correct icon on the top left on the Options Bar. That way you can get a Path instead of a Shape Layer.
    Once you have your Path you can stroke it with a Brush or any drawing tool. Various options appear in the Brushes palette. For a dotted line you will need to increase the spacing. If you want dashes, use a square brush and set the Angle Jitter to Direction.

  • "I want to draw a line, and it will highlight when I click it."

    I am currently working on a project right now. My project is a structural analysis software for civil engineers. Our project is already at it's infant
    stage of development. I am having trouble with how to implement drawing on a canvas. Heres the specs:
    -There are nodes on the drawing board illustrated by dots.
    -Lines must be drawn connecting the nodes.
    -Nodes must be a separate object where it could respond to mouse
    events.
    -Lines must also be a separate object where it could respond to mouse
    events.
    -Nodes and lines contain mathematical attributes, color information.
    -I can instantly delete a line, or change its attributes by selecting
    it.
    Heres what I have imagined:
    -I am going to draw my Nodes in a JPanel which implements a
    mouseListener.
    -Whenever I want to add nodes to the drawing board, I only have to add
    the Node objects i created.
    No problem with the nodes. Problem is in the lines i will be drawingconnecting one node to another.
    -I tried manual live drawing of the lines as the mouse moves. Now its
    flat on the drawing board. It can't be touched!
    -I still don't have any idea how to implement the line that it could
    respond to mouse events.
    -If I try to draw it in a JPanel with mouseListener, a JPanel is square
    so if I move my mouse to point in to the line drawn on the JPanel, it
    will already respond before the mouse could reach the line image. One
    thing also, it could overlap other JPanels.
    -The JPanel idea came up to my mind coz I thought these objects could
    be
    selectable custom components.
    -Now I realized JPanel is not the ANSWER!
    In simple saying:
    "I want to draw a line, and it will highlight when I click it."
    Stubborn Newbie,
    Edgar

    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import javax.swing.*;
    public class SelectingLines extends JPanel
        Line2D.Double[] lines;
        int selectedIndex = -1;
        protected void paintComponent(Graphics g)
            super.paintComponent(g);
            Graphics2D g2 = (Graphics2D)g;
            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                                RenderingHints.VALUE_ANTIALIAS_ON);
            if(lines == null)
                initLines();
            for(int j = 0; j < lines.length; j++)
                Color color = Color.blue;
                if(j == selectedIndex)
                    color = Color.green.darker();
                g2.setPaint(color);
                g2.draw(lines[j]);
        public void setSelection(int index)
            selectedIndex = index;
            repaint();
        private void initLines()
            lines = new Line2D.Double[3];
            int w = getWidth();
            int h = getHeight();
            lines[0] = new Line2D.Double(w/8, h/8, w/3, h/6);
            lines[1] = new Line2D.Double(w/3, h/6, w/2, h/2);
            lines[2] = new Line2D.Double(w/2, h/2, w*5/8, h*7/12);
        public static void main(String[] args)
            SelectingLines selectPanel = new SelectingLines();
            selectPanel.addMouseListener(new LineSelector(selectPanel));
            JFrame f = new JFrame();
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.getContentPane().add(selectPanel);
            f.setSize(400,400);
            f.setLocation(200,200);
            f.setVisible(true);
    class LineSelector extends MouseAdapter
        SelectingLines selectingLines;
        Rectangle r;
        final int S = 4;
        public LineSelector(SelectingLines sl)
            selectingLines = sl;
            r = new Rectangle(S, S);
        public void mousePressed(MouseEvent e)
            Point p = e.getPoint();
            r.setLocation(p.x-S/2, p.y-S/2);
            Line2D.Double[] lines = selectingLines.lines;
            int index = -1;
            for(int j = 0; j < lines.length; j++)
                if(lines[j].intersects(r))
                    index = j;
                    break;
            if(index != selectingLines.selectedIndex)
                selectingLines.setSelection(index);
    }

  • Can I create dotted lines in smartforms

    Dear All,
    I want to create dotted lines for tables in msartforms.
    Is it possible.?
    Thanks,
    Aneel

    Hi aneel,
    i don't think dotted lines are possible in smartforms.you can use text box draw underscore's(_) or dots(.) but this should be the last to be displayed in adjustable form or another way is using syuline ,dots and syvline in your code in the table...
    hope this solves ur query.

Maybe you are looking for

  • Moving audio files around that are not in the iTunes library

    Hi, Can someone please confirm some behaviour for me. This is regarding iTunes (on OS X naturally) and moving files around that aren't located within the iTunes library. Most of the files I use are located within the iTunes library, they are fine. Ho

  • OIM11gR2 : BP06 Patch deployment error

    Hello Experts, I am trying to apply BP06 patch to OIM 11gR2. I get the following error in the logs when i run opatch apply : [May 6, 2013 10:27:58 PM] Command invocation returned Error... 'chmod: cannot access `/users/oim/Oracle/Middleware/oracle_com

  • ACSv3.2 with 802.1x client authenticaiton using LEAP

    Hi there, I was wondering if this has happened to anyone here. I have a Windows 2000 Server running ACSv3.2 - Once every 4 months ACS will fail to authenticate all the wireless users that have Active Directory accounts. Auth-Failure code: ?External D

  • DCNM 6.2 Install on N1010, how to generate a CSR ??

    Hi, does anyone know the process of generating a Cerificate Signing Request fpr DCNM 6.2 on N1010 ? This process is only documented for windows --> http://www.cisco.com/en/US/docs/switches/datacenter/sw/6_x/dcnm/fundamentals/guide/dcnm/DCNM-SAN-LAN_p

  • Enhanced messagebox() with customized return values.

    Is there a function built in to vfp where I can do a messagebox type of a dialog but with my own options? For example if I want to have a dialog with "Send email, Don't send email, OK, Cancel" as my options. Or should one write his own? Thanks.