I would like to show my own icon instead of the Java cup in the window.
Also when minimized, I would like to display, my own image. How will I be able to do so?
And where should I position my image relative to the source file?
[UPDATE]
I tried but no luck
TrayIcon trayIcon = new TrayIcon(Toolkit.getDefaultToolkit().createImage("image/accounting.gif"));
//setIconImage();
SystemTray tray = SystemTray.getSystemTray();
try {
tray.add(trayIcon);
} catch (AWTException e) {
System.out.println("TrayIcon could not be added.");
}
Also i tried
TrayIcon trayIcon = new TrayIcon(createImage("images/bulb.gif", "tray icon"));
But seriously doubt createImage(
and even if it is Object don't know what to import.
Regards,
I havent written about tray icon but Finally I found the main issue in setting the jframe icon. Here is my code. It is similar to other codes but here are few things to mind the game.
1) Put this code in jframe WindowOpened event
2) Put Image in main folder where all of your form and java files are created e.g.
3) And most important that name of file is case sensitive that is icon.png won't work but Icon.png.
this way your icon will be there even after finally building your project.
An example using setIconImages() : (same applies for setIconImage())
The clue is in using the "getImage()" in order to return the Image (as ImageIcon can not be used directly in setIconImages() ).
Use
JFrame.setIconImage()
Regarding your
TrayIcon
issue, you can refer below for a solution: