2
* @(#)QuaquaColorPreviewPanel.java 1.2 2005-12-18
4
* Copyright (c) 2005 Werner Randelshofer
5
* Staldenmattweg 2, Immensee, CH-6405, Switzerland.
8
* This software is the confidential and proprietary information of
9
* Werner Randelshofer. ("Confidential Information"). You shall not
10
* disclose such Confidential Information and shall use it only in
11
* accordance with the terms of the license agreement you entered into
12
* with Werner Randelshofer.
15
package org.pushingpixels.substance.internal.contrib.randelshofer.quaqua.colorchooser;
18
import java.awt.event.*;
20
import javax.swing.plaf.*;
22
import org.pushingpixels.substance.internal.contrib.randelshofer.quaqua.*;
25
* QuaquaColorPreviewPanel.
27
* @author Werner Randelshofer
28
* @version 1.2 2005-12-18 Tweaked insets.
29
* <br>1.1 2005-09-20 Added tooltip. This is not what the native
30
* NSColorPicker does, but it is very useful.
31
* <br>1.0 30 March 2005 Created.
33
public class QuaquaColorPreviewPanel extends JPanel implements UIResource {
34
private final static Color previewBorderColor = new Color(0x949494);
35
private final static Color previewBackgroundColor = new Color(0xffffff);
36
/** Creates new form. */
37
public QuaquaColorPreviewPanel() {
39
setBorder(new VisualMargin(3,0,3,0));
40
setToolTipText("on"); // set dummy text, to switch tooltip on
44
public void paintComponent(Graphics g) {
45
Insets insets = getInsets();
48
int w = getWidth() - insets.left - insets.right;
49
int h = getHeight() - insets.top - insets.bottom;
50
g.setColor(previewBackgroundColor);
51
g.fillRect(x+1,y+1,w-2,h-2);
52
g.setColor(previewBorderColor);
53
g.drawRect(x,y,w-1,h-1);
54
g.setColor(getForeground());
55
g.fillRect(x+2,y+2,w-4,h-4);
59
public String getToolTipText(MouseEvent evt) {
60
Color color = getForeground();
61
return (color == null) ? null : color.getRed()+", "+ color.getGreen() + ", " + color.getBlue();
64
/** This method is called from within the constructor to
65
* initialize the form.
66
* WARNING: Do NOT modify this code. The content of this method is
67
* always regenerated by the Form Editor.
69
private void initComponents() {//GEN-BEGIN:initComponents
71
setLayout(new java.awt.BorderLayout());
73
setPreferredSize(new java.awt.Dimension(26, 26));
74
}//GEN-END:initComponents
77
// Variables declaration - do not modify//GEN-BEGIN:variables
78
// End of variables declaration//GEN-END:variables