Search code examples
javadraw2d

how to set line width & color of connection line in draw2d?


I am trying to set width and color of connection line in draw2d. I found method "setLineWidth()" method but on what I need to call this method. I call this method on input port object but did not work. Plz help me.


Solution

  • Can you please post some of your code? This is working for me:

        PolylineConnection connection = new PolylineConnection();
        connection.setLineWidth(2);
        connection.setSourceAnchor(new ChannelStartAnchor(this));
        connection.setTargetAnchor(new ChannelEndAnchor(figure));
    
    
        Display display = Display.getCurrent();
        final Color connectionColorHoover = display.getSystemColor(SWT.COLOR_RED);
        final Color connectionColor = new Color(display,54,82,111);
        connection.setBackgroundColor(connectionColor);
        connection.setForegroundColor(connectionColor);