public void paint(Graphics2D g) {
    JBHiDPIScaledImage image = myImage;
    if (image == null) {
      return;
    }

    myFpsMeter.paintFrameStarted();
    VolatileImage vi = myVolatileImage;

    do {
      boolean contentOutdated = myContentOutdated;
      myContentOutdated = false;
      if (vi == null || vi.getWidth() != image.getWidth() || vi.getHeight() != image.getHeight()) {
        vi = createVolatileImage(g, image.getWidth(), image.getHeight());
      }
      else if (contentOutdated) {
        drawVolatileImage(vi);
      }

      switch (vi.validate(g.getDeviceConfiguration())) {
        case VolatileImage.IMAGE_RESTORED -> drawVolatileImage(vi);
        case VolatileImage.IMAGE_INCOMPATIBLE -> vi = createVolatileImage(g, image.getWidth(), image.getHeight());
      }

      g.drawImage(vi, 0, 0, null);
    }
    while (vi.contentsLost());

    myVolatileImage = vi;

    myFpsMeter.paintFrameFinished(g);
  }
public void paint(Graphics2D g)