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?
source
share