protected void writeFrame() {


    if (pixelWriter != null) {
      while (!imageState.compareAndSet(WAITING_STATE, RUNNING_STATE)) {
        if (imageState.get() == DISPOSED_STATE) {
          return;
        }
      }

      try {

        final int[] imageDataBuffer = getImageByteBuffer();

        synchronized (byteBuffer) {
          
          for(int i = 0; i < width * height; i++) {
            imageDataBuffer[i] =   ((0xff & byteBuffer[i*4+3]) << 24)  // Alpha 
                                 | ((0xff & byteBuffer[i*4])   << 16)  // Red
                                 | ((0xff & byteBuffer[i*4+1]) <<  8)  // Green 
                                 | ((0xff & byteBuffer[i*4+2]));       // BLue
            
          }
        }

        DataBuffer buffer = new DataBufferInt(imageDataBuffer, imageDataBuffer.length);

        SampleModel sm = new  SinglePixelPackedSampleModel(DataBuffer.TYPE_INT, getWidth(), getHeight(), new int[] {0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000});

        WritableRaster raster = Raster.createWritableRaster(sm, buffer, null);
        
        BufferedImage img = new BufferedImage(colorModel, raster, false, null);
        
        BufferedImage img2 = new BufferedImage(getWidth(), getHeight(), BufferedImage.TYPE_INT_ARGB);
        offGraphics = img2.createGraphics();
        offGraphics.setColor(component.getBackground());
        img2.createGraphics().fillRect(0, 0, getWidth(), getHeight());
        img2.createGraphics().drawImage(img, null, null);    

        component.getGraphics().drawImage(img2, 0, 0, null);

      } finally {
        if (!imageState.compareAndSet(RUNNING_STATE, WAITING_STATE)) {
          throw new RuntimeException("unknown problem with the image state");
        }
      }
    } else {
      System.out.println("No graphics context available for rendering.");
    }


  }
Write the current rendered frame to the component graphics context.
jme3-desktop/src/main/java/com/jme3/system/AWTComponentRenderer.java