Sketch works with P2D but doesn't update with JAVA2D

Hi! Any ideas on why this program fails to draw different lines when clicking the mouse on JAVA2D, but does work with P2D? (on Processing 0269). Maybe it works on previous versions?

In JAVA2D it seems to draw always the same line when clicking, which might suggest that the temp layer is not updated. On the other hand, the temp layer is drawn continuously on the screen, and it is obviously changing.

PGraphics result, temp;
float len = 5, lenSpeed = 0;
float angle = 0, angleSpeed = 0;

// This program tries to demonstrate a concept for drawing.

// Instead of implementing an undo feature, a better option may be to show
// in real time how the drawing is going to look like when clicking the mouse.

// That way undo is not necessary, because you see the result in advance, interactively.
// This allows to search for the right design, instead of the "try (random result) + undo" approach.

int W = 800;
int H = 800;
String MODE = P2D; // P2D | JAVA2D

void settings() {
  size(W, H, MODE);
}

void setup() {
  result = createGraphics(W, H, MODE);  
  result.beginDraw();
  result.background(0);
  result.endDraw();

  temp = createGraphics(W, H, MODE);
  temp.beginDraw();
  temp.noFill();
  temp.stroke(255);
  temp.endDraw();
}

void draw() {
  checkKeys();

  // I think this background should not be unnecessary 
  // because pg should have an opaque background.
  background(0);
  
  updateTemp();
  image(result, 0, 0);
  image(temp, 0, 0);
}

void updateTemp() {
  len += lenSpeed;
  angle += angleSpeed;
  lenSpeed *= 0.9;
  angleSpeed *= 0.9;

  temp.beginDraw();
  temp.background(255, 0);
  float x = mouseX;
  float y = mouseY;
  temp.beginShape();
  for (int i=0; i<100; i++) {
    temp.vertex(x, y);
    float a = angle + TAU * noise(x * 0.01, y * 0.01);
    x += len * cos(a);
    y += len * sin(a);
  }
  temp.endShape();
  temp.endDraw();
}

void mousePressed() {
  // Here the transparency of pg seems to be changed,
  // even if I assume pg should keep its opaque background
  result.beginDraw();
  result.image(temp, 0, 0);
  result.endDraw();
}


void checkKeys() {
  if (keyPressed) {
    switch(keyCode) {
    case UP:
      lenSpeed += 0.003;
      break;
    case DOWN:
      lenSpeed -= 0.003;
      break;
    case LEFT:
      angleSpeed += 0.003;
      break;
    case RIGHT:
      angleSpeed -= 0.003;
      break;
    }
  }
}

Any suggestions on improving the antialiasing? I tried with different combinations of clear() and background() with either black or white transparency, but nothing seemed to help. Currently it looks better while the line is inside temp, but as soon as it is transferred to result the antialias is seriously injured.