root / trunk / libraries / libUIComponent / src-test-ui / org / gvsig / gui / beans / listview / TestListView.java @ 12623
History | View | Annotate | Download (3.97 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.listview; |
20 |
|
21 |
import java.awt.BorderLayout; |
22 |
import java.awt.Dimension; |
23 |
import java.awt.GridBagConstraints; |
24 |
import java.awt.event.ActionEvent; |
25 |
import java.awt.event.ActionListener; |
26 |
|
27 |
import javax.swing.JButton; |
28 |
import javax.swing.JCheckBox; |
29 |
import javax.swing.JFrame; |
30 |
import javax.swing.JPanel; |
31 |
import javax.swing.JScrollPane; |
32 |
|
33 |
import org.gvsig.gui.beans.listview.ListViewComponent; |
34 |
import org.gvsig.gui.beans.listview.ListViewItem; |
35 |
/**
|
36 |
* @version 28/06/2007
|
37 |
* @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es)
|
38 |
*/
|
39 |
public class TestListView implements ActionListener { |
40 |
private JFrame jFrame = null; |
41 |
private JScrollPane jScrollPane = null; |
42 |
private ListViewComponent listViewComponent = null; |
43 |
JButton botonAdd = null; |
44 |
JButton botonDel = null; |
45 |
JCheckBox multiselect = null; |
46 |
|
47 |
public TestListView() {
|
48 |
initialize(); |
49 |
} |
50 |
|
51 |
private void initialize() { |
52 |
jFrame = new JFrame(); |
53 |
jScrollPane = new JScrollPane(); |
54 |
|
55 |
listViewComponent = new ListViewComponent();
|
56 |
listViewComponent.setEditable(true);
|
57 |
jScrollPane.setViewportView(listViewComponent); |
58 |
|
59 |
for (int i=0; i<20000; i++) { |
60 |
ListViewItem item = new ListViewItem(new RampPainter(), "Prueba-" + i); |
61 |
listViewComponent.addItem(item, true);
|
62 |
} |
63 |
|
64 |
JPanel jpane = new JPanel(); |
65 |
jpane.setLayout(new BorderLayout()); |
66 |
jpane.add(jScrollPane, BorderLayout.CENTER);
|
67 |
|
68 |
JPanel jPanel1 = new JPanel(); |
69 |
jPanel1.setLayout(new java.awt.GridBagLayout());
|
70 |
|
71 |
jpane.add(jPanel1, BorderLayout.SOUTH);
|
72 |
|
73 |
botonAdd = new JButton("Add"); |
74 |
botonAdd.addActionListener(this);
|
75 |
GridBagConstraints gridBagConstraints = new GridBagConstraints(); |
76 |
gridBagConstraints.insets = new java.awt.Insets(5, 5, 2, 2); |
77 |
jPanel1.add(botonAdd, gridBagConstraints); |
78 |
|
79 |
botonDel = new JButton("Del"); |
80 |
botonDel.addActionListener(this);
|
81 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
82 |
gridBagConstraints.gridx = 1;
|
83 |
gridBagConstraints.gridy = 0;
|
84 |
gridBagConstraints.insets = new java.awt.Insets(5, 2, 2, 5); |
85 |
jPanel1.add(botonDel, gridBagConstraints); |
86 |
|
87 |
multiselect = new JCheckBox("MultiSelect"); |
88 |
multiselect.addActionListener(this);
|
89 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
90 |
gridBagConstraints.gridx = 0;
|
91 |
gridBagConstraints.gridy = 1;
|
92 |
gridBagConstraints.gridwidth = 2;
|
93 |
gridBagConstraints.insets = new java.awt.Insets(2, 5, 5, 5); |
94 |
jPanel1.add(multiselect, gridBagConstraints); |
95 |
|
96 |
|
97 |
jFrame.setSize(new Dimension(192, 300)); |
98 |
jFrame.setContentPane(jpane); |
99 |
|
100 |
jFrame.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); |
101 |
jFrame.setVisible(true);
|
102 |
} |
103 |
|
104 |
/**
|
105 |
* @param args
|
106 |
*/
|
107 |
public static void main(String[] args) { |
108 |
new TestListView();
|
109 |
} |
110 |
|
111 |
int id = 0; |
112 |
/*
|
113 |
* (non-Javadoc)
|
114 |
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
|
115 |
*/
|
116 |
public void actionPerformed(ActionEvent e) { |
117 |
if (e.getSource() == botonAdd) {
|
118 |
ListViewItem item = new ListViewItem(new RampPainter(), "Prueba"); |
119 |
listViewComponent.addItem(item); |
120 |
return;
|
121 |
} |
122 |
|
123 |
if (e.getSource() == botonDel) {
|
124 |
listViewComponent.removeSelecteds(); |
125 |
return;
|
126 |
} |
127 |
|
128 |
if (e.getSource() == multiselect) {
|
129 |
listViewComponent.setMultiSelect(multiselect.isSelected()); |
130 |
return;
|
131 |
} |
132 |
} |
133 |
} |