root / trunk / libraries / libUIComponent / src / org / gvsig / gui / beans / colorbutton / ColorButtonDialog.java @ 12939
History | View | Annotate | Download (3.19 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.colorbutton; |
20 |
|
21 |
import java.awt.Color; |
22 |
import java.awt.Dimension; |
23 |
|
24 |
import javax.swing.JDialog; |
25 |
|
26 |
import org.gvsig.gui.beans.buttonspanel.ButtonsPanel; |
27 |
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelEvent; |
28 |
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelListener; |
29 |
import org.gvsig.gui.beans.colorchooser.ColorChooser; |
30 |
import org.gvsig.gui.beans.colorchooser.ColorChooserListener; |
31 |
import org.gvsig.gui.beans.defaultbuttonspanel.DefaultButtonsPanel; |
32 |
/**
|
33 |
*
|
34 |
* @version 06/08/2007
|
35 |
* @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es)
|
36 |
*/
|
37 |
public class ColorButtonDialog extends JDialog implements ButtonsPanelListener { |
38 |
private static final long serialVersionUID = -6452724233113608938L; |
39 |
private DefaultButtonsPanel defaultButtonsPanel = null; |
40 |
private ColorChooser colorChooser = null; |
41 |
private boolean result = false; |
42 |
|
43 |
public ColorButtonDialog() {
|
44 |
initialize(); |
45 |
} |
46 |
|
47 |
private void initialize() { |
48 |
setResizable(false);
|
49 |
setTitle("Selector de color");
|
50 |
defaultButtonsPanel = new DefaultButtonsPanel(ButtonsPanel.BUTTONS_ACCEPTCANCEL);
|
51 |
defaultButtonsPanel.getButtonsPanel().setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.CENTER, 7, 0)); |
52 |
add(defaultButtonsPanel); |
53 |
colorChooser = new ColorChooser();
|
54 |
defaultButtonsPanel.add(colorChooser); |
55 |
defaultButtonsPanel.addButtonPressedListener(this);
|
56 |
colorChooser.setPreferredSize(new Dimension(220, (int) colorChooser.getPreferredSize().getHeight())); |
57 |
pack(); |
58 |
} |
59 |
|
60 |
/**
|
61 |
* @param listener
|
62 |
* @see org.gvsig.gui.beans.colorchooser.ColorChooser#addValueChangedListener(org.gvsig.gui.beans.colorchooser.ColorChooserListener)
|
63 |
*/
|
64 |
public void addValueChangedListener(ColorChooserListener listener) { |
65 |
colorChooser.addValueChangedListener(listener); |
66 |
} |
67 |
|
68 |
/**
|
69 |
* @return
|
70 |
* @see org.gvsig.gui.beans.colorchooser.ColorChooser#getColor()
|
71 |
*/
|
72 |
public Color getColor() { |
73 |
return colorChooser.getColor();
|
74 |
} |
75 |
|
76 |
/**
|
77 |
* @param value
|
78 |
* @see org.gvsig.gui.beans.colorchooser.ColorChooser#setColor(java.awt.Color)
|
79 |
*/
|
80 |
public void setColor(Color value) { |
81 |
colorChooser.setColor(value); |
82 |
} |
83 |
|
84 |
public boolean showDialog() { |
85 |
setModal(true);
|
86 |
setVisible(true);
|
87 |
return result;
|
88 |
} |
89 |
|
90 |
public void actionButtonPressed(ButtonsPanelEvent e) { |
91 |
switch (e.getButton()) {
|
92 |
case ButtonsPanel.BUTTON_ACCEPT:
|
93 |
result = true;
|
94 |
case ButtonsPanel.BUTTON_CANCEL:
|
95 |
this.setVisible(false); |
96 |
break;
|
97 |
} |
98 |
} |
99 |
} |