Advertisement
Advertisement
| 07.21.2008 at 11:59PM PDT, ID: 23584316 | Points: 500 |
|
[x]
Attachment Details
|
||
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: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: |
//code snippet for timer
actionlistner t_ac=
t_ac = new ActionListener() {
public void actionPerformed(ActionEvent e) {
// jButton1ActionPerformed(null);
// jButton4ActionPerformed(null);
//t_sendTRD.run();
// t_RecvTRD.run();
formWindowOpened(null);
}
};
m_MainTmr = new Timer(1000, t_ac);
m_MainTmr.start();
//To draw trayIcon
private void DrawTrayIcon() {
SystemTray tray = SystemTray.getSystemTray();
Image image = Toolkit.getDefaultToolkit().getImage("C:\\Documents and Settings\\XML\\Globe.jpg");
final JPopupMenu popup = new JPopupMenu();
JMenuItem item = new JMenuItem("Exit");
JMenuItem ite = new JMenuItem("jjklk");
popup.add(item);
popup.add(ite);
TrayIcon trayIcon = new TrayIcon(image, "Right Click", null);
javax.swing.Action t_acc = new javax.swing.Action() {
public Object getValue(String key) {
throw new UnsupportedOperationException("Not supported yet.");
}
public void putValue(String key, Object value) {
throw new UnsupportedOperationException("Not supported yet.");
}
public void setEnabled(boolean b) {
throw new UnsupportedOperationException("Not supported yet.");
}
public boolean isEnabled() {
throw new UnsupportedOperationException("Not supported yet.");
}
public void addPropertyChangeListener(PropertyChangeListener listener) {
throw new UnsupportedOperationException("Not supported yet.");
}
public void removePropertyChangeListener(PropertyChangeListener listener) {
throw new UnsupportedOperationException("Not supported yet.");
}
public void actionPerformed(ActionEvent e) {
if (e.getActionCommand().equalsIgnoreCase("EXIT")) {
System.exit(0);
}
}
};
ite.addActionListener(t_acc);
item.addActionListener(t_acc);
trayIcon.addMouseListener(new MouseListener() {
public void mouseClicked(MouseEvent e) {
}
public void mousePressed(MouseEvent e) {
if (e.getButton() == MouseEvent.BUTTON3) {
if (e.isPopupTrigger()) {
try {
popup.setLocation(e.getX(), e.getY());
popup.setInvoker(popup);
popup.setVisible(true);
Thread.sleep(MouseEvent.MOUSE_EVENT_MASK);
} catch (InterruptedException ex) {
Logger.getLogger(ApprovalUtility.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
}
public void mouseReleased(MouseEvent e) {
if (e.getButton() == MouseEvent.BUTTON3) {
if (e.isPopupTrigger()) {
popup.setLocation(e.getX(), e.getY());
popup.setInvoker(popup);
popup.setVisible(true);
}
}
}
public void mouseEntered(MouseEvent e) {
throw new UnsupportedOperationException("Not supported yet.");
}
public void mouseExited(MouseEvent e) {
throw new UnsupportedOperationException("Not supported yet.");
}
});
try {
tray.add(trayIcon);
} catch (AWTException e) {
System.err.println("Can't add to tray");
}
}
|