From: <doc...@us...> - 2007-08-21 20:15:16
|
Revision: 157 http://openpcl.svn.sourceforge.net/openpcl/?rev=157&view=rev Author: documentsystems Date: 2007-08-21 13:14:39 -0700 (Tue, 21 Aug 2007) Log Message: ----------- Howard Hoagland. Changed PosToolbarDropdownItemRenderer to change the background color on JLabels in JLists by which one the mouse is hovering over, which was set in PosHoverColorMouseMotionAdapter so the user has visual confirmation of which item in the drop down will be seleced if clicked there. Modified Paths: -------------- openpcl/src/com/openpcl/viewer/util/PosToolbarDropdownItemRenderer.java Modified: openpcl/src/com/openpcl/viewer/util/PosToolbarDropdownItemRenderer.java =================================================================== --- openpcl/src/com/openpcl/viewer/util/PosToolbarDropdownItemRenderer.java 2007-08-21 20:09:04 UTC (rev 156) +++ openpcl/src/com/openpcl/viewer/util/PosToolbarDropdownItemRenderer.java 2007-08-21 20:14:39 UTC (rev 157) @@ -1,10 +1,13 @@ package com.openpcl.viewer.util; +import java.awt.Color; import java.awt.Component; import javax.swing.DefaultListCellRenderer; import javax.swing.JLabel; import javax.swing.JList; +import javax.swing.SwingConstants; +import javax.swing.UIManager; /** * Subclass of the DefaultListCellRenderer which is a subclass of JLabel. @@ -17,6 +20,8 @@ */ public class PosToolbarDropdownItemRenderer extends DefaultListCellRenderer { private static final long serialVersionUID = 1L; + private Color mBkgSelectionColor = null; + private Color mBkgNonSelectionColor = null; @Override public Component getListCellRendererComponent( @@ -24,11 +29,23 @@ super.getListCellRendererComponent(pList, pValue, pIndex, pIsSelected, pCellHasFocus); - + + // Need to get the color again every time because the user might have changed the Look and Feel from last time + mBkgSelectionColor = UIManager.getColor("List.selectionBackground"); + mBkgNonSelectionColor = UIManager.getColor("List.background"); + if (pValue instanceof JLabel) { JLabel tJLabel = (JLabel)pValue; setIcon(tJLabel.getIcon()); setText(tJLabel.getText()); + + if (tJLabel.getVerticalAlignment() == SwingConstants.TOP) { + // Setting the vertical alignment to TOP doesn't change the text placement when a JLabel is in a JList, but this + // is a trick to use something in a JLabel to know which JLabel in the JList the mouse is hovering over right now. + setBackground(mBkgSelectionColor); + } else { + setBackground(mBkgNonSelectionColor); + } } return this; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <doc...@us...> - 2007-09-12 21:46:57
|
Revision: 168 http://openpcl.svn.sourceforge.net/openpcl/?rev=168&view=rev Author: documentsystems Date: 2007-09-12 14:46:58 -0700 (Wed, 12 Sep 2007) Log Message: ----------- Howard Hoagland. Added text color change in addition to the already background color change as user hovers over the different choices in the toolbar button drop down dialogs. Modified Paths: -------------- openpcl/src/com/openpcl/viewer/util/PosToolbarDropdownItemRenderer.java Modified: openpcl/src/com/openpcl/viewer/util/PosToolbarDropdownItemRenderer.java =================================================================== --- openpcl/src/com/openpcl/viewer/util/PosToolbarDropdownItemRenderer.java 2007-09-08 00:53:51 UTC (rev 167) +++ openpcl/src/com/openpcl/viewer/util/PosToolbarDropdownItemRenderer.java 2007-09-12 21:46:58 UTC (rev 168) @@ -21,7 +21,9 @@ public class PosToolbarDropdownItemRenderer extends DefaultListCellRenderer { private static final long serialVersionUID = 1L; private Color mBkgSelectionColor = null; + private Color mFrgSelectionColor = null; private Color mBkgNonSelectionColor = null; + private Color mFrgNonSelectionColor = null; @Override public Component getListCellRendererComponent( @@ -32,7 +34,9 @@ // Need to get the color again every time because the user might have changed the Look and Feel from last time mBkgSelectionColor = UIManager.getColor("List.selectionBackground"); + mFrgSelectionColor = UIManager.getColor("List.selectionForeground"); mBkgNonSelectionColor = UIManager.getColor("List.background"); + mFrgNonSelectionColor = UIManager.getColor("List.foreground"); if (pValue instanceof JLabel) { JLabel tJLabel = (JLabel)pValue; @@ -43,8 +47,10 @@ // Setting the vertical alignment to TOP doesn't change the text placement when a JLabel is in a JList, but this // is a trick to use something in a JLabel to know which JLabel in the JList the mouse is hovering over right now. setBackground(mBkgSelectionColor); + setForeground(mFrgSelectionColor); } else { setBackground(mBkgNonSelectionColor); + setForeground(mFrgNonSelectionColor); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |