} Graphics2D g = (Graphics2D) tex.getGraphics(); g.drawImage(image, null, null);
} AffineTransform tx = null; if (flipImage) { tx = AffineTransform.getScaleInstance(1, -1); tx.translate(0, -image.getHeight(null)); }  Graphics2D g = (Graphics2D) tex.getGraphics(); g.drawImage(image, tx, null);
  public static com.jme.image.Image loadImage(java.awt.Image image,                                              boolean flipImage) {    boolean hasAlpha = hasAlpha(image);    //      Obtain the image data.    BufferedImage tex = null;    try {      tex = new BufferedImage(image.getWidth(null),                              image.getHeight(null), hasAlpha                              ? BufferedImage.TYPE_4BYTE_ABGR                              : BufferedImage.TYPE_3BYTE_BGR);    }    catch (IllegalArgumentException e) {      LoggingSystem.getLogger().log(Level.WARNING,                                    "Problem creating buffered Image: " +                                    e.getMessage());      return null;    }    Graphics2D g = (Graphics2D) tex.getGraphics();    g.drawImage(image, null, null);    g.dispose();    if (flipImage) {      //Flip the image      AffineTransform tx = AffineTransform.getScaleInstance(1, -1);      tx.translate(0, -image.getHeight(null));      AffineTransformOp op = new AffineTransformOp(tx,          AffineTransformOp.TYPE_NEAREST_NEIGHBOR);      tex = op.filter(tex, null);    }    //Get a pointer to the image memory    ByteBuffer scratch = ByteBuffer.allocateDirect(4 * tex.getWidth()        * tex.getHeight());    byte data[] = (byte[]) tex.getRaster().getDataElements(0, 0,        tex.getWidth(), tex.getHeight(), null);    scratch.clear();    scratch.put(data);    scratch.rewind();    com.jme.image.Image textureImage = new com.jme.image.Image();    textureImage.setType(hasAlpha                         ? com.jme.image.Image.RGBA8888                         : com.jme.image.Image.RGB888);    textureImage.setWidth(tex.getWidth());    textureImage.setHeight(tex.getHeight());    textureImage.setData(scratch);    return textureImage;  }