svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.library / org.gvsig.ui / src / test / java / org / gvsig / gui / beans / doubleslider / TestDoubleSlider.java @ 40561
History | View | Annotate | Download (2.43 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright (C) 2007-2013 gvSIG Association.
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 3
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
* For any additional information, do not hesitate to contact us
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
23 |
*/
|
24 |
package org.gvsig.gui.beans.doubleslider; |
25 |
|
26 |
import java.awt.BorderLayout; |
27 |
import java.awt.Dimension; |
28 |
|
29 |
import javax.swing.JFrame; |
30 |
import javax.swing.JPanel; |
31 |
|
32 |
public class TestDoubleSlider implements DoubleSliderListener { |
33 |
private JFrame jFrame = null; |
34 |
private DoubleSlider doubleSlider = null; |
35 |
private JPanel jPanel = null; |
36 |
|
37 |
public TestDoubleSlider() {
|
38 |
jFrame = new JFrame(); |
39 |
jFrame.setSize(new Dimension(498, 267)); |
40 |
jFrame.setContentPane(getJPanel()); |
41 |
jFrame.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); |
42 |
jFrame.setVisible(true);
|
43 |
} |
44 |
|
45 |
/**
|
46 |
* This method initializes multiSlider
|
47 |
*
|
48 |
* @return borsanza.src.multislider.MultiSlider
|
49 |
*/
|
50 |
private DoubleSlider getMultiSlider() {
|
51 |
if (doubleSlider == null) { |
52 |
doubleSlider = new DoubleSlider();
|
53 |
doubleSlider.setMinimum(0);
|
54 |
doubleSlider.setMaximum(255);
|
55 |
doubleSlider.addValueChangedListener(this);
|
56 |
} |
57 |
return doubleSlider;
|
58 |
} |
59 |
|
60 |
/**
|
61 |
* This method initializes jPanel
|
62 |
*
|
63 |
* @return javax.swing.JPanel
|
64 |
*/
|
65 |
private JPanel getJPanel() { |
66 |
if (jPanel == null) { |
67 |
jPanel = new JPanel(); |
68 |
jPanel.setLayout(new BorderLayout()); |
69 |
jPanel.add(getMultiSlider(), BorderLayout.CENTER);
|
70 |
} |
71 |
return jPanel;
|
72 |
} |
73 |
|
74 |
public static void main(String[] args) { |
75 |
new TestDoubleSlider();
|
76 |
} |
77 |
|
78 |
public void actionValueChanged(DoubleSliderEvent e) { |
79 |
System.out.println("Changed: " + getMultiSlider().getValue()); |
80 |
} |
81 |
|
82 |
public void actionValueDragged(DoubleSliderEvent e) { |
83 |
System.out.println("Dragged: " + getMultiSlider().getValue()); |
84 |
} |
85 |
} |