Author: jerome
Date: 2008-08-18 10:07:08 +0200 (Mon, 18 Aug 2008)
New Revision: 1548
Modified:
software_suite_v2/software/control_center/trunk/control_center/sources/com/tuxdroid/cc/CcInterface.java
Log:
* Improved tray icon.
Modified:
software_suite_v2/software/control_center/trunk/control_center/sources/com/tuxdroid/cc/CcInterface.java
===================================================================
---
software_suite_v2/software/control_center/trunk/control_center/sources/com/tuxdroid/cc/CcInterface.java
2008-08-18 07:44:43 UTC (rev 1547)
+++
software_suite_v2/software/control_center/trunk/control_center/sources/com/tuxdroid/cc/CcInterface.java
2008-08-18 08:07:08 UTC (rev 1548)
@@ -73,6 +73,8 @@
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.border.BevelBorder;
+import javax.swing.event.PopupMenuEvent;
+import javax.swing.event.PopupMenuListener;
import javax.swing.plaf.InsetsUIResource;
import org.jdesktop.jdic.tray.SystemTray;
@@ -296,6 +298,18 @@
}
+ public void menuTrayChange(JMenuItem item){
+ if(item.getText().equals(language.getTrayHideCaption())){
+ item.setText(language.getTrayShowCaption());
+ jFrame.setVisible(false);
+ }
+ else if(item.getText().equals(language.getTrayShowCaption())){
+ item.setText(language.getTrayHideCaption());
+ jFrame.setVisible(true);
+ }
+ }
+
+
private void setTrayIcon(){
menuTray = new JPopupMenu("A Menu");
@@ -305,14 +319,7 @@
item1.addMouseListener(new java.awt.event.MouseAdapter(){
public void mousePressed(java.awt.event.MouseEvent
event){
-
if(item1.getText().equals(language.getTrayHideCaption())){
-
item1.setText(language.getTrayShowCaption());
- jFrame.setVisible(false);
- }
- else
if(item1.getText().equals(language.getTrayShowCaption())){
-
item1.setText(language.getTrayHideCaption());
- jFrame.setVisible(true);
- }
+ menuTrayChange(item1);
}
});
@@ -325,10 +332,26 @@
menuTray.add(item1);
menuTray.add(item2);
+ menuTray.addPopupMenuListener(new PopupMenuListener(){
+
+ public void popupMenuCanceled(PopupMenuEvent arg0) {}
+
+ public void popupMenuWillBecomeInvisible(PopupMenuEvent
arg0) {}
+
+ public void popupMenuWillBecomeVisible(PopupMenuEvent
arg0) {
+ menuTray.setLocation(new
Point(tray.getLocationOnScreen().x -3,
+
tray.getLocationOnScreen().y-50));
+ }
+
+ });
+
tray = new TrayIcon(tray_offline, "TuxDroid Cc", menuTray);
tray.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent event){
- menuTray.show(null
,tray.getLocationOnScreen().x + 4, tray.getLocationOnScreen().y);
+
+ if(!menuTray.isVisible()){
+ menuTrayChange(item1);
+ }
}
});
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Tux-droid-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tux-droid-svn