Why does the setAconImage Java AWT FileDialog method not allow the icon to be set?

I am trying to use Java AWT FileDialog, but I want to replace the default Java icon with something else. In short, the code looks something like this:

Frame frame = new Frame();
Image image = ImageIO.read(new URL("file:/path/to/myfile.jpg"));
FileDialog fileDialog = new FileDialog(frame, "Save As", FileDialog.SAVE);

fileDialog.setIconImage(image);
fileDialog.setDirectory("/path/to/directory");
fileDialog.setFile("filename.txt");

fileDialog.setVisible(true);

I tried several options, including another way of reading an image, packing FileDialog, packing a frame, setting a frame icon, etc. However, no matter what I try, the FileDialog icon never changes. When I set the frame icon and set the frame to visible, the correct icon is displayed in the frame, but it is still not necessary for FileDialog.

Any thoughts?

+3
source share
2 answers

FileDialog, AWT, . Solaris java, .

, JFileChooser?

+2

. , FileDialog - filedialog, , , .

+1

Source: https://habr.com/ru/post/1723725/


All Articles