harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aiva...@apache.org
Subject svn commit: r574155 - /harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/colorchooser/SwatchesPanel.java
Date Mon, 10 Sep 2007 07:15:35 GMT
Author: aivanov
Date: Mon Sep 10 00:15:35 2007
New Revision: 574155

URL: http://svn.apache.org/viewvc?rev=574155&view=rev
Log:
Fixing HARMONY-2714: Recent color swatches in j.s.JColorChooser are not clickable
This patch also fixes HARMONY-2713: j.s.JColorChooser does not show Color value in tooltip

Modified:
    harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/colorchooser/SwatchesPanel.java

Modified: harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/colorchooser/SwatchesPanel.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/colorchooser/SwatchesPanel.java?rev=574155&r1=574154&r2=574155&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/colorchooser/SwatchesPanel.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/colorchooser/SwatchesPanel.java
Mon Sep 10 00:15:35 2007
@@ -46,7 +46,24 @@
     private SwatchPanel recentPanel;
     private SwatchPanel swatchPanel;
 
-    private static class SwatchPanel extends JPanel {
+    private final class SwatchPanelMouseInputAdapter extends MouseInputAdapter {
+    	private SwatchPanel panel;
+
+    	SwatchPanelMouseInputAdapter(final SwatchPanel panel) {
+    		this.panel = panel;
+    	}
+
+		public void mouseClicked(final MouseEvent e) {
+		    getColorSelectionModel().setSelectedColor(panel.getColorAtLocation(e.getX(), e.getY(),
true));
+		}
+
+		public void mouseMoved(final MouseEvent e) {
+		    Color color = panel.getColorAtLocation(e.getX(), e.getY(), false);
+		    panel.setToolTipText(color.getRed() + ", " + color.getGreen() + ", " + color.getBlue());
+		}
+	}
+
+	private static class SwatchPanel extends JPanel {
         int oneColorWidth;
         int oneColorHeight;
 
@@ -135,20 +152,15 @@
 
         JPanel right = new JPanel(new BorderLayout());
         recentPanel = new SwatchPanel(createRecentColors(), null, recentSwatchSize);
-        
+        MouseInputAdapter swatchMouseAdapter = new SwatchPanelMouseInputAdapter(recentPanel);
+        recentPanel.addMouseListener(swatchMouseAdapter);
+        recentPanel.addMouseMotionListener(swatchMouseAdapter);
+
         right.add(BorderLayout.CENTER, new JLabel(UIManager.getString("ColorChooser.swatchesRecentText")));
         right.add(BorderLayout.SOUTH, recentPanel);
 
         swatchPanel = new SwatchPanel(MAIN_SWATCH_COLORS, recentPanel, swatchSize);
-        MouseInputAdapter swatchMouseAdapter = new MouseInputAdapter() {
-            public void mouseClicked(MouseEvent e) {
-                getColorSelectionModel().setSelectedColor(swatchPanel.getColorAtLocation(e.getX(),
e.getY(), true));
-            }
-            public void mouseMoved(MouseEvent e) {
-                Color color = swatchPanel.getColorAtLocation(e.getX(), e.getY(), false);
-                swatchPanel.setToolTipText(color.getRed() + ", " + color.getGreen() + ",
" + color.getBlue());
-            }
-        };
+        swatchMouseAdapter = new SwatchPanelMouseInputAdapter(swatchPanel);
         swatchPanel.addMouseListener(swatchMouseAdapter);
         swatchPanel.addMouseMotionListener(swatchMouseAdapter);
 



Mime
View raw message