From: Anneli <an...@us...> - 2005-03-18 14:15:52
|
Update of /cvsroot/redpos/RedPOS/src/org/redpos/client/ui/plugin In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6369/src/org/redpos/client/ui/plugin Modified Files: PluginFactory.java Log Message: Change color on buttons with focus Index: PluginFactory.java =================================================================== RCS file: /cvsroot/redpos/RedPOS/src/org/redpos/client/ui/plugin/PluginFactory.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PluginFactory.java 23 Nov 2004 16:02:03 -0000 1.1 --- PluginFactory.java 18 Mar 2005 14:15:43 -0000 1.2 *************** *** 32,37 **** --- 32,41 ---- import org.eclipse.swt.SWT; + import org.eclipse.swt.events.FocusAdapter; + import org.eclipse.swt.events.FocusEvent; + import org.eclipse.swt.events.FocusListener; import org.eclipse.swt.events.TraverseEvent; import org.eclipse.swt.events.TraverseListener; + import org.eclipse.swt.graphics.Color; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.widgets.Button; *************** *** 55,58 **** --- 59,66 ---- private static PluginFactory theInstance = null; + + private static Color blue; + + private static Color black; /** *************** *** 90,93 **** --- 98,103 ---- PluginCategoryUtility categoryUtility) { + blue = new Color(parent.getDisplay(),51,51,255); + black = new Color(parent.getDisplay(),0,0,0); // create a vector for ze buttons Vector buttons = new Vector(); *************** *** 162,165 **** --- 172,200 ---- layoutData.verticalAlignment = GridData.FILL; button.setLayoutData(layoutData); + + // create focus listener for button + FocusListener buttonFocusListener = new FocusAdapter() + { + public void focusGained(FocusEvent e) + { + // when the button receives the focus, change color + if(e.widget instanceof Button) + { + Button button = (Button)e.widget; + button.setForeground(blue); + } + } + + public void focusLost(FocusEvent e) + { + // when the button receives the focus, go back to default color + if(e.widget instanceof Button) + { + Button button = (Button)e.widget; + button.setForeground(black); + } + } + }; + button.addFocusListener(buttonFocusListener); buttons.add(button); |