root / trunk / libraries / libCq_CMS_praster / src / org / cresques / ui / BrightnessContrast / CheckSliderText.java @ 8026
History | View | Annotate | Download (2.95 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2004 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 |
|
20 |
package org.cresques.ui.BrightnessContrast; |
21 |
|
22 |
import java.awt.GridBagConstraints; |
23 |
import java.awt.Insets; |
24 |
import java.awt.event.ActionEvent; |
25 |
import java.awt.event.ActionListener; |
26 |
|
27 |
import javax.swing.JCheckBox; |
28 |
import javax.swing.JLabel; |
29 |
|
30 |
/**
|
31 |
* Clase que contiene slider, campo de texto, etiqueta para el nombre y un
|
32 |
* checkBox para habilitar o deshabilitar el slider y el campo de texto.
|
33 |
* @author Miguel ?ngel Querol Carratal? <querol_mig@gva.es>
|
34 |
*
|
35 |
*/
|
36 |
public class CheckSliderText extends SliderTextPanel implements ActionListener{ |
37 |
|
38 |
public JLabel lName = null; |
39 |
public JCheckBox cSliderText = null; |
40 |
|
41 |
/**
|
42 |
* Constructor
|
43 |
*
|
44 |
*/
|
45 |
|
46 |
public CheckSliderText(){
|
47 |
GridBagConstraints gridBagConstraints1 = new GridBagConstraints(); |
48 |
gridBagConstraints1.insets = new Insets(0,0,0,0); |
49 |
super.getJPanel().add(getJCheckBox());
|
50 |
super.getJPanel().add(getLName(), gridBagConstraints1);
|
51 |
this.getJCheckBox().addActionListener(this); |
52 |
if(cSliderText.isSelected() == false){ |
53 |
super.setControlEnabled(false); |
54 |
} |
55 |
} |
56 |
/**
|
57 |
* Inicializa cSliderText
|
58 |
* @return
|
59 |
*/
|
60 |
public JCheckBox getJCheckBox(){ |
61 |
if(cSliderText == null){ |
62 |
cSliderText = new JCheckBox(); |
63 |
} |
64 |
return cSliderText;
|
65 |
} |
66 |
|
67 |
public JLabel getLName(){ |
68 |
if(lName == null){ |
69 |
lName = new JLabel(); |
70 |
lName.setText("Nombre");
|
71 |
lName.setPreferredSize(new java.awt.Dimension(150,15)); |
72 |
lName.setSize(150, 15); |
73 |
} |
74 |
return lName;
|
75 |
} |
76 |
|
77 |
/**
|
78 |
* Pone nombre al panel en la etiqueta que est? encima del slider
|
79 |
*/
|
80 |
public void setName(String name){ |
81 |
lName.setText(name); |
82 |
} |
83 |
|
84 |
/**
|
85 |
* Activa o desactiva el slider y el campo de texto
|
86 |
*/
|
87 |
public void setControlEnabled(boolean active){ |
88 |
this.cSliderText.setEnabled(active);
|
89 |
this.lName.setEnabled(active);
|
90 |
this.getJTextField().setEnabled(active);
|
91 |
super.setControlEnabled(active);
|
92 |
if(cSliderText.isSelected() == false){ |
93 |
super.setControlEnabled(false); |
94 |
} |
95 |
|
96 |
} |
97 |
|
98 |
|
99 |
public void actionPerformed(ActionEvent e) { |
100 |
super.actionPerformed(e);
|
101 |
if (e.getSource() == getJCheckBox()){
|
102 |
super.setControlEnabled(getJCheckBox().isSelected());
|
103 |
} |
104 |
} |
105 |
|
106 |
public void setSelected(boolean value){ |
107 |
this.getJCheckBox().setSelected(value);
|
108 |
} |
109 |
|
110 |
} |