The system pallet is the icon in the lower right corner of the desktop. Essence
The function implemented by this program is to click the window closing button to not exit the program, but hides in the system pallet.
In essence, the window is not visible. Essence Essence
Import java.awt.awtexception; Import Java.awt.Menuitem; Import Java.awt.popupMenu; Import Java.Awt.Systemtray; Import port java.awt.event.actionevent; import java.awt.event .ACTIONLISTENER; Import Java.awt.Event.WindowAdapter; Import Java.awt.Event.windowEvent; Import javax.swing.imageicon; Import javax.swing.jframe ; Public Class TestTray Extends Jframe {Private Static Final Long SerialVersionuid = -707803031139039390L; public testtray () {this.setsize (500, 400); this.setLocationRelationoTo (null); // Set the window in the middle of the screen systemtray (); // Set the system pallet // Hide the window to this.addwindowListener (New WindowAdapter () {@Override Public Void WindowClossing (Windowevent E) {testtray.this.setvisible (false);}) ; this.setvisible (true);} /*** processing system Trip*/Private void Systemtray () {if (SystemTray.issupPorted ()) {// Deciding whether the system supports the tray function. // Create a handle right -click the popup menu PopupupMenu = New Popupmenu (); In the menu Exit Menuitem itemexit = New Menuitem ("Exit System"); Itemexit.AdDACTIONLISTENER (New ActionListener () {@Override Public Void ActionPerformed E) { System.exit (0);}}); PopupMenu.add (ITEMEXIT) ; // Create a pallet icon imageicon icon = New Imageicon ("IMG/Icon.png"); // Create a picture object to (icon.getimage (), "test system pallet", "test system tray", " Icon.adDactionListener (New ActionListener () {@Override Public Void ActionPerformed (ActionEvent E) {testtray.this.setvisible (true);}}); // Put it in the pallet Here, the opening program directly displays the tray icon. Try {SystemTray.getSystemtray (). Add (Tra on (Tra on);} Catch (AWTexception E1) {e1.printstacktrace ();} public static main (string [] args) {new testtray ();}}