View Javadoc
1   package com.nilhcem.fakesmtp.gui;
2   
3   import com.nilhcem.fakesmtp.core.I18n;
4   import com.nilhcem.fakesmtp.gui.listeners.AboutActionListener;
5   import com.nilhcem.fakesmtp.gui.listeners.ExitActionListener;
6   import java.awt.MenuItem;
7   import java.awt.PopupMenu;
8   
9   /**
10   * Provides the popup menu for the SystemTray icon.
11   *
12   * @author Vest
13   * @since 2.1
14   */
15  public class TrayPopup {
16  
17  	private final I18n i18n = I18n.INSTANCE;
18  	private final PopupMenu popup = new PopupMenu();
19  
20  	/**
21  	 * The popup menu used by the icon in the system tray.
22  	 *
23  	 * @param mainFrame MainFrame class.
24  	 */
25  	public TrayPopup(final MainFrame mainFrame) {
26  		// Create a popup menu components
27  		MenuItem aboutItem = new MenuItem(i18n.get("menubar.about"));
28  		aboutItem.addActionListener(new AboutActionListener(null));
29  
30  		MenuItem exitItem = new MenuItem(i18n.get("menubar.exit"));
31  		exitItem.addActionListener(new ExitActionListener(mainFrame));
32  
33  		popup.add(aboutItem);
34  		popup.addSeparator();
35  		popup.add(exitItem);
36  	}
37  
38  	/**
39  	 * Returns the PopupMenu object.
40  	 *
41  	 * @return the PopupMenu object.
42  	 */
43  	public PopupMenu get() {
44  		return popup;
45  	}
46  }