Statistics
| Revision:

root / trunk / libraries / libUIComponent / src / org / gvsig / gui / beans / buttonscolor / ButtonColor.java @ 12438

History | View | Annotate | Download (2.04 KB)

1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 */
19
package org.gvsig.gui.beans.buttonscolor;
20

    
21
import java.awt.Color;
22
import java.awt.Dimension;
23
import java.awt.event.ActionEvent;
24
import java.awt.event.ActionListener;
25

    
26
import javax.swing.JButton;
27
import javax.swing.JColorChooser;
28

    
29
import org.gvsig.gui.beans.messages.Messages;
30
/**
31
 * Componente de selecci?n de un color
32
 *
33
 * @version 02/07/2007
34
 * @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es)
35
 */
36
public class ButtonColor extends JButton implements ActionListener {
37
        private static final long serialVersionUID = 8037973734807388692L;
38

    
39
        public ButtonColor() {
40
                setText("");
41
                setPreferredSize(new Dimension(34, 16));
42
                addActionListener(this);
43
                setBackground(Color.WHITE);
44
                setOpaque(true);
45
        }
46

    
47
        /*
48
         * (non-Javadoc)
49
         * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
50
         */
51
        public void actionPerformed(ActionEvent e) {
52
                Color ret = JColorChooser.showDialog(this, Messages.getText("select_color"), getBackground());
53

    
54
                if (ret != null)
55
                        setBackground(ret);
56
        }
57

    
58
        /**
59
         * Obtiene el color
60
         * @return
61
         */
62
        public Color getColor() {
63
                return getBackground();
64
        }
65

    
66
        /**
67
         * Especifica el color
68
         * @param color
69
         */
70
        public void setColor(Color color) {
71
                setBackground(color);
72
        }
73
}