Revision 22758 branches/v2_0_0_prep/libraries/libUIComponent/src/org/gvsig/gui/beans/checkslidertext/CheckSliderTextContainer.java

View differences:

CheckSliderTextContainer.java
27 27
import java.awt.event.ActionListener;
28 28

  
29 29
import javax.swing.JCheckBox;
30
import javax.swing.JLabel;
30 31
import javax.swing.JPanel;
31 32

  
32 33
import org.gvsig.gui.beans.slidertext.SliderTextContainer;
......
38 39
 * @author Nacho Brodin(nachobrodin@gmail.com) 
39 40
 */
40 41
public class CheckSliderTextContainer extends SliderTextContainer implements ActionListener{
41
	private static final long serialVersionUID = -542842897847364459L;
42
	public JCheckBox          check            = null;
43
	private JPanel            pLabel           = null;
44
	private String            text             = null;
42
	private static final long serialVersionUID  = -542842897847364459L;
43
	public JCheckBox          check             = null;
44
	private JPanel            pLabel            = null;
45
	private String            text              = null;
46
	private boolean           showCheck         = true;
47
	private JLabel            labelWithoutCheck = null;
45 48

  
46 49
	/**
47 50
	 * Constructor	
......
51 54
	 * @param up Si es true el texto se coloca sobre el componente y si es false a la izquierda 
52 55
	 * @param txt Texto de la etiqueta del check
53 56
	 * @param active Valor por defecto del control.True activo y false desactivo
57
	 * @deprecated Es recomendable el uso del constructor con el par?metro border. Tiene la misma funcionalidad 
58
	 * si se pone ese par?metro a true. Se mantiene este constructor por compatibilidad con versiones 
59
	 * anteriores.
54 60
	 */
55 61
	public CheckSliderTextContainer(int min, int max, int defaultPos, boolean up, String txt, boolean active){
56
		super(min, max, defaultPos);
62
		this(min, max, defaultPos, up, txt, active, false, true);
63
	}
64
	
65
	/**
66
	 * Constructor	
67
	 * @param min Valor m?nimo del slider
68
	 * @param max Valor m?ximo del slider
69
	 * @param defaultPos Posici?n inicial
70
	 * @param up Si es true el texto se coloca sobre el componente y si es false a la izquierda 
71
	 * @param txt Texto de la etiqueta del check
72
	 * @param active Valor por defecto del control.True activo y false desactivo
73
	 * @param border True para mostrar el borde al control y false para ocultarlo
74
	 * @param showCheck True para mostrar el checkbox de activaci?n y desactivaci?n. False para ocultarlo
75
	 */
76
	public CheckSliderTextContainer(int min, int max, int defaultPos, boolean up, String txt, boolean active, boolean border, boolean showCheck) {
77
		super(min, max, defaultPos, border);
78
		this.showCheck = showCheck;
57 79
		text = txt;
58 80
		GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
59 81
		gridBagConstraints1.insets = new Insets(0,0,0,0);
......
61 83
			super.add(getPCheck(up), BorderLayout.WEST);
62 84
		else
63 85
			super.add(getPCheck(up), BorderLayout.NORTH);
64
		check.addActionListener(this);
65
		check.setSelected(active);
86
		if(showCheck) {
87
			check.addActionListener(this);
88
			check.setSelected(active);
89
		}
66 90
		setControlEnabled(active);
67 91
	}
68 92

  
......
76 100
			pLabel = new JPanel();
77 101
			if (!up) {
78 102
				GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
79
				gridBagConstraints1.insets = new java.awt.Insets(0, 10, 13, 0);
80 103
				pLabel.setLayout(new GridBagLayout());
81
				pLabel.add(getCheck(), gridBagConstraints1);
104
				if(showCheck) {
105
					gridBagConstraints1.insets = new java.awt.Insets(0, 10, 13, 0);
106
					pLabel.add(getCheck(), gridBagConstraints1);
107
				} else {
108
					gridBagConstraints1.insets = new java.awt.Insets(0, 0, 13, 0);
109
					labelWithoutCheck = new JLabel(text); 
110
					pLabel.add(labelWithoutCheck, gridBagConstraints1);
111
				}
82 112
			} else {
83 113
				FlowLayout fl = new FlowLayout();
84 114
				fl.setAlignment(FlowLayout.LEFT);
85 115
				pLabel.setLayout(fl);
86
				pLabel.add(getCheck(), null);
116
				if(showCheck)
117
					pLabel.add(getCheck(), null);
118
				else {
119
					labelWithoutCheck = new JLabel(text); 
120
					pLabel.add(labelWithoutCheck, null);
121
				}
87 122
			}
88 123
		}
89 124
		return pLabel;
......
104 139
	 * @param active
105 140
	 */
106 141
	public void setControlEnabled(boolean active) {
107
		getCheck().setSelected(active);
142
		if(showCheck)
143
			getCheck().setSelected(active);
144
		if(labelWithoutCheck != null)
145
			labelWithoutCheck.setEnabled(active);
108 146
		super.setControlEnabled(active);
109 147
	}
110 148

  

Also available in: Unified diff