The direct method,
But some issues to note that the final will explain!
Private void SystemTray () { IF (SystemTray.isSupported ()) { // determine whether the system tray support function. // Create a tray right-click popup menu PopupMenu popupMenu = new new PopupMenu (); // create exit pop-up menu items MenuItem = itemExit new new the MenuItem ( "the Exit" ); itemExit.addActionListener ( new new the ActionListener () { @Override public void the actionPerformed (the ActionEvent E) { System.exit ( 0 ); } }); popupMenu.add (itemExit); // create a tray icon ImageIcon icon = new new ImageIcon (getClass () getResource ( "Image / timg.jpg." )); // create a picture object TrayIcon trayIcon = new new TrayIcon (icon.getImage () , "Scan the Upload" , popupMenu); // very important phrase, or tray icon is not displayed! ! ! trayIcon.setImageAutoSize ( to true ); trayIcon.addActionListener ( new new the ActionListener () { @Override public void the actionPerformed (the ActionEvent E) { TwainADF_VerificationForm. the this .setVisible ( to true ); } }); // add to the system tray icon tray // This can then click to close the tray and then put inside this open display tray icon of the program direct the try { SystemTray.getSystemTray () the Add (trayIcon);. } the catch (of AWTException E1) { e1.printStackTrace (); } } }
JDialog cancel the top right off event
this.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
PS:
1 shows a blank picture
trayIcon.setImageAutoSize (true); This sentence must be
2 pictures stored path problem:
At the same level this class, create image folders, go into the picture.
Then copied to the target directory, copy to the same level as the same class