forked from vin8bit/Library-Management-System
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSysTray.java
More file actions
40 lines (35 loc) · 1.07 KB
/
Copy pathSysTray.java
File metadata and controls
40 lines (35 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class SysTray
{
public static void Gui()
{
if(!SystemTray.isSupported())
{ System.out.println("SystemTray is not Supported "); return; }
SystemTray systray= SystemTray.getSystemTray();
Toolkit kit = Toolkit.getDefaultToolkit();
Image img= kit.getImage("image/Red_book.png");
PopupMenu pop= new PopupMenu();
MenuItem item= new MenuItem("Library Login");
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{ new Login(); }});
pop.add(item);
MenuItem item2= new MenuItem("Exit");
item2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{ System.exit(0); }});
pop.add(item2);
TrayIcon icon = new TrayIcon(img,"Library vk ",pop);
icon.setImageAutoSize(true);
try{ systray.add(icon); }
catch(AWTException e)
{ System.out.println("Cannot be added"); }
}
/*public static void main(String []args)
{
SwingUtilities.invokeLater(new Runnable(){
public void run(){ Gui(); } });
}*/
}