title: Drawing rounded rectangle while dragging fails
body: <p>I am trying to draw a simple rectangle with rounded corners in javafx while dragging the mouse. 
  First issue: I can't make the upper-left corner rounded. 
  Second issue: I want my application to be able to draw nice and full rounded rectangles not like the second one from my picture.
  Please, how can I fix these?
  Thanks in advance for your help.</p>
  
  <p>Here is my code: </p>
  
  <pre><code>import javafx.application.Application;
  import javafx.event.EventHandler;
  import javafx.scene.Group;
  import javafx.scene.Scene;
  import javafx.scene.input.MouseEvent;
  import javafx.scene.layout.BorderPane;
  import javafx.scene.paint.Color;
  import javafx.scene.shape.Rectangle;
  import javafx.stage.Stage;
  
  public class Main extends Application {
    public static void main(String[] args) {
        launch(args);
    }
  
    public void start(Stage stage){
        stage.setTitle("Test");        
        root = new BorderPane();     
        Scene scene = new Scene(root, 400, 400);
        paintings = new Group();
        stage.setScene(scene);
  
        canvas = new Rectangle(0, 0, stage.getScene().getWidth(), stage.getScene().getHeight());
        canvas.setFill(Color.WHITE);
  
        addHandlers();
  
        root.setCenter(canvas);  
        root.getChildren().add(paintings);
        stage.show();
     }
  
    private void paintRectangle(){
        roundedRect = new Rectangle(pressedX, 
                      pressedY, 
                      draggedX - pressedX, 
                      draggedY - pressedY);
        roundedRect.setFill(Color.RED);
        roundedRect.setArcHeight(40);
        roundedRect.setArcWidth(40);        
        paintings.getChildren().add(roundedRect);
    }
  
    private void addHandlers(){
       canvas.setOnMousePressed(new EventHandler&lt;MouseEvent&gt;() {
  
            @Override
            public void handle(MouseEvent me) {                
                pressedX = me.getX();
                pressedY = me.getY();
            }
        });
  
       canvas.setOnMouseReleased(new EventHandler&lt;MouseEvent&gt;() {
  
            @Override
            public void handle(MouseEvent me) {                
                /* If I make the drawing in here, I get round corners, but it doesn't get drawn while dragging*/
                //paintRectangle();
            }
        });
  
        canvas.setOnMouseDragged(new EventHandler&lt;MouseEvent&gt;() {
  
            @Override
            public void handle(MouseEvent me) {                
                draggedX =  me.getX();
                draggedY =  me.getY();
                paintRectangle();
  
            }
        });
    }
    double pressedX, pressedY;
    double draggedX, draggedY;
    Rectangle canvas;
    Group paintings;
    Rectangle roundedRect;
    BorderPane root;
  
  }
  </code></pre>
  
  <p>And here is my picture: 
  <img src="https://i.stack.imgur.com/Jq9Qi.jpg" alt="not the rounded rectangles that I expected"></p>