# The method getImage() from the type PImage is deprecated

**URL:** <https://discourse.processing.org/t/the-method-getimage-from-the-type-pimage-is-deprecated/47297>\
**Category:** Coding Questions\
**Created:** [October 8, 2025, 2:57pm UTC](https://discourse.processing.org/t/the-method-getimage-from-the-type-pimage-is-deprecated/47297 "2025-10-08T14:57:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bonner45](https://avatars.discourse-cdn.com/v4/letter/b/53a042/32.png) [@bonner45](https://discourse.processing.org/u/bonner45)\
**Post date:** [October 8, 2025, 2:57pm UTC](https://discourse.processing.org/t/the-method-getimage-from-the-type-pimage-is-deprecated/47297/1 "2025-10-08T14:57:07Z")

</div>

```processing
void settingsUI() {
  frameSettings = new JFrame("Settings");
  frameSettings.setSize(500, 300);
  frameSettings.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
  frameSettings.setResizable(false);
  frameSettings.setIconImage(icon.getImage());
  pnlMainSettings = new JPanel();
  pnlMainSettings.setBackground(Color.white);
  pnlMainSettings.setLayout(layoutSettings);
  //add components here
  drawPortConfig();
  drawDataConfig();
  drawLogConfig();
  frameSettings.add(pnlMainSettings);
  frameSettings.setLocationRelativeTo(null);
  frameSettings.setVisible(true);
}

```

Does anyone know what is the proper way to set a javaSwing JFrame icon.

This code works fine but the compiler says The method getImage() from the type PImage is deprecated.(I believe its converting an PImage to Image)

```processing
frameSettings.setIconImage(icon.getImage());

```

Any suggestions appreciated Thanks.

FYI:

Running vscode extension on WIN 10

---

<div class="post-metadata">

**Author:** ![bonner45](https://avatars.discourse-cdn.com/v4/letter/b/53a042/32.png) [@bonner45](https://discourse.processing.org/u/bonner45)\
**Post date:** [October 8, 2025, 4:27pm UTC](https://discourse.processing.org/t/the-method-getimage-from-the-type-pimage-is-deprecated/47297/2 "2025-10-08T16:27:14Z")

</div>

The solution is to convert it to a buffered image.

```processing
BufferedImage convertToBufferedImage(PImage imgToConvert) {
  imgToConvert.loadPixels(); //load pixel data
  BufferedImage convertedImg = new BufferedImage(imgToConvert.width, imgToConvert.height, BufferedImage.TYPE_INT_ARGB);

  for (int y = 0; y < imgToConvert.height; y++) {
    for (int x = 0; x < imgToConvert.width; x++) {
      int loc = x + y * imgToConvert.width;
      convertedImg.setRGB(x, y, imgToConvert.pixels[loc]); // Copy pixel data
    }
  }
  return convertedImg;
}

```

```processing
BufferedImage javaIcon = convertToBufferedImage(icon);

```

Final code.

```processing
//draw main ui for settings window
void settingsUI() {
  frameSettings = new JFrame("Settings");
  frameSettings.setSize(500, 300);
  frameSettings.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
  frameSettings.setResizable(false);
  BufferedImage javaIcon = convertToBufferedImage(icon);
  frameSettings.setIconImage(javaIcon);
  pnlMainSettings = new JPanel();
  pnlMainSettings.setBackground(Color.white);
  pnlMainSettings.setLayout(layoutSettings);
  //add components here
  drawPortConfig();
  drawDataConfig();
  drawLogConfig();
  frameSettings.add(pnlMainSettings);
  frameSettings.setLocationRelativeTo(null);
  frameSettings.setVisible(true);
}

```
