0

I'm trying to set an Icon for a Message Alert popup, and I'm using the methods I've found online. However, they're causing issues where the image:

  1. Doesn't even get set as the icon
  2. Is way too oversized
  3. Placed in the JPanel

The screenshot below shows what I mean:

Screenshot of Issue

And my code doesn't seem to have any issues:

final ImageIcon iconF = new ImageIcon(LOGIN.class.getResource("/resources/offline.png"));
JOptionPane.showMessageDialog(null, "ERROR: Please check your username and password then try again.", "Login Failed", JOptionPane.ERROR_MESSAGE, iconF);

I don't understand what's causing this mess of an issue when this seems to be the "answer" to my own question.

PackOf20
  • 334
  • 2
  • 17
  • Yeah I know, but that still doesn't fix my issue that it won't be set as an Icon. – PackOf20 Sep 19 '21 at 14:59
  • I want to change the window icon. Displayed in the image at the top left corner is the small default java icon I'm attempting to change. – PackOf20 Sep 19 '21 at 15:04
  • So I'm guessing it's not possible to change? And why would they call it an Icon if it's not an icon and just a image slapped on the surface of a JOptionPane – PackOf20 Sep 19 '21 at 15:08
  • Thanks, Ill take a look – PackOf20 Sep 19 '21 at 15:19
  • Pass a non-null component as the first argument to showMessageDialog. That will cause the dialog to inherit its window icon from its parent. As for your comment, the term “icon” refers to any small image. It has never been a term that only referred to the application image in window manager decorations or task switchers. – VGR Sep 19 '21 at 15:36

0 Answers0