gvsig-projects-pool / org.gvsig.busquedacatastral / trunk / org.gvsig.busquedacatastral / org.gvsig.busquedacatastral.swing / org.gvsig.busquedacatastral.swing.impl / src / main / java / org / gvsig / busquedacatastral / swing / impl / BusquedaNumerosPanelView.java @ 140
History | View | Annotate | Download (6.59 KB)
1 |
package org.gvsig.busquedacatastral.swing.impl; |
---|---|
2 |
|
3 |
import com.jgoodies.forms.layout.CellConstraints; |
4 |
import com.jgoodies.forms.layout.FormLayout; |
5 |
import java.awt.BorderLayout; |
6 |
import java.awt.ComponentOrientation; |
7 |
import java.awt.Container; |
8 |
import java.awt.Dimension; |
9 |
import javax.swing.Box; |
10 |
import javax.swing.ImageIcon; |
11 |
import javax.swing.JButton; |
12 |
import javax.swing.JFrame; |
13 |
import javax.swing.JLabel; |
14 |
import javax.swing.JList; |
15 |
import javax.swing.JPanel; |
16 |
import javax.swing.JScrollPane; |
17 |
import javax.swing.JTextField; |
18 |
|
19 |
|
20 |
public class BusquedaNumerosPanelView extends JPanel |
21 |
{ |
22 |
JLabel lblMunicipio = new JLabel(); |
23 |
JLabel lblProvincia = new JLabel(); |
24 |
JTextField txtProvincia = new JTextField(); |
25 |
JTextField txtMunicipio = new JTextField(); |
26 |
JList listNumeros = new JList(); |
27 |
JButton btnAceptar = new JButton(); |
28 |
JButton btnCancelar = new JButton(); |
29 |
JLabel lblVia = new JLabel(); |
30 |
JTextField txtVia = new JTextField(); |
31 |
JLabel lblDesde = new JLabel(); |
32 |
JTextField txtDesde = new JTextField(); |
33 |
JLabel lblHasta = new JLabel(); |
34 |
JTextField txtHasta = new JTextField(); |
35 |
JButton btnBuscar = new JButton(); |
36 |
|
37 |
/**
|
38 |
* Default constructor
|
39 |
*/
|
40 |
public BusquedaNumerosPanelView()
|
41 |
{ |
42 |
initializePanel(); |
43 |
} |
44 |
|
45 |
/**
|
46 |
* Adds fill components to empty cells in the first row and first column of the grid.
|
47 |
* This ensures that the grid spacing will be the same as shown in the designer.
|
48 |
* @param cols an array of column indices in the first row where fill components should be added.
|
49 |
* @param rows an array of row indices in the first column where fill components should be added.
|
50 |
*/
|
51 |
void addFillComponents( Container panel, int[] cols, int[] rows ) |
52 |
{ |
53 |
Dimension filler = new Dimension(10,10); |
54 |
|
55 |
boolean filled_cell_11 = false; |
56 |
CellConstraints cc = new CellConstraints();
|
57 |
if ( cols.length > 0 && rows.length > 0 ) |
58 |
{ |
59 |
if ( cols[0] == 1 && rows[0] == 1 ) |
60 |
{ |
61 |
/** add a rigid area */
|
62 |
panel.add( Box.createRigidArea( filler ), cc.xy(1,1) ); |
63 |
filled_cell_11 = true;
|
64 |
} |
65 |
} |
66 |
|
67 |
for( int index = 0; index < cols.length; index++ ) |
68 |
{ |
69 |
if ( cols[index] == 1 && filled_cell_11 ) |
70 |
{ |
71 |
continue;
|
72 |
} |
73 |
panel.add( Box.createRigidArea( filler ), cc.xy(cols[index],1) ); |
74 |
} |
75 |
|
76 |
for( int index = 0; index < rows.length; index++ ) |
77 |
{ |
78 |
if ( rows[index] == 1 && filled_cell_11 ) |
79 |
{ |
80 |
continue;
|
81 |
} |
82 |
panel.add( Box.createRigidArea( filler ), cc.xy(1,rows[index]) ); |
83 |
} |
84 |
|
85 |
} |
86 |
|
87 |
/**
|
88 |
* Helper method to load an image file from the CLASSPATH
|
89 |
* @param imageName the package and name of the file to load relative to the CLASSPATH
|
90 |
* @return an ImageIcon instance with the specified image file
|
91 |
* @throws IllegalArgumentException if the image resource cannot be loaded.
|
92 |
*/
|
93 |
public ImageIcon loadImage( String imageName ) |
94 |
{ |
95 |
try
|
96 |
{ |
97 |
ClassLoader classloader = getClass().getClassLoader();
|
98 |
java.net.URL url = classloader.getResource( imageName ); |
99 |
if ( url != null ) |
100 |
{ |
101 |
ImageIcon icon = new ImageIcon( url ); |
102 |
return icon;
|
103 |
} |
104 |
} |
105 |
catch( Exception e ) |
106 |
{ |
107 |
e.printStackTrace(); |
108 |
} |
109 |
throw new IllegalArgumentException( "Unable to load image: " + imageName ); |
110 |
} |
111 |
|
112 |
/**
|
113 |
* Method for recalculating the component orientation for
|
114 |
* right-to-left Locales.
|
115 |
* @param orientation the component orientation to be applied
|
116 |
*/
|
117 |
public void applyComponentOrientation( ComponentOrientation orientation ) |
118 |
{ |
119 |
// Not yet implemented...
|
120 |
// I18NUtils.applyComponentOrientation(this, orientation);
|
121 |
super.applyComponentOrientation(orientation);
|
122 |
} |
123 |
|
124 |
public JPanel createPanel() |
125 |
{ |
126 |
JPanel jpanel1 = new JPanel(); |
127 |
FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:41PX:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:41PX:NONE,FILL:DEFAULT:NONE,FILL:91PX:NONE,FILL:55PX:NONE,FILL:96PX:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:136PX:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE"); |
128 |
CellConstraints cc = new CellConstraints();
|
129 |
jpanel1.setLayout(formlayout1); |
130 |
|
131 |
lblMunicipio.setName("lblMunicipio");
|
132 |
lblMunicipio.setText("_municipio");
|
133 |
jpanel1.add(lblMunicipio,cc.xy(2,4)); |
134 |
|
135 |
lblProvincia.setName("lblProvincia");
|
136 |
lblProvincia.setText("_provincia");
|
137 |
jpanel1.add(lblProvincia,cc.xy(2,2)); |
138 |
|
139 |
txtProvincia.setName("txtProvincia");
|
140 |
jpanel1.add(txtProvincia,cc.xywh(4,2,8,1)); |
141 |
|
142 |
txtMunicipio.setName("txtMunicipio");
|
143 |
jpanel1.add(txtMunicipio,cc.xywh(4,4,8,1)); |
144 |
|
145 |
listNumeros.setName("listNumeros");
|
146 |
JScrollPane jscrollpane1 = new JScrollPane(); |
147 |
jscrollpane1.setViewportView(listNumeros); |
148 |
jscrollpane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
|
149 |
jscrollpane1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
150 |
jpanel1.add(jscrollpane1,cc.xywh(4,10,12,1)); |
151 |
|
152 |
btnAceptar.setActionCommand("JButton");
|
153 |
btnAceptar.setName("btnAceptar");
|
154 |
btnAceptar.setText("_aceptar");
|
155 |
jpanel1.add(btnAceptar,cc.xy(12,12)); |
156 |
|
157 |
btnCancelar.setActionCommand("JButton");
|
158 |
btnCancelar.setName("btnCancelar");
|
159 |
btnCancelar.setText("_cancelar");
|
160 |
jpanel1.add(btnCancelar,cc.xy(14,12)); |
161 |
|
162 |
lblVia.setName("lblVia");
|
163 |
lblVia.setText("_via");
|
164 |
jpanel1.add(lblVia,cc.xy(2,6)); |
165 |
|
166 |
txtVia.setName("txtVia");
|
167 |
jpanel1.add(txtVia,cc.xywh(4,6,8,1)); |
168 |
|
169 |
lblDesde.setName("lblDesde");
|
170 |
lblDesde.setText("_desde");
|
171 |
jpanel1.add(lblDesde,cc.xy(2,8)); |
172 |
|
173 |
txtDesde.setName("txtDesde");
|
174 |
jpanel1.add(txtDesde,cc.xy(4,8)); |
175 |
|
176 |
lblHasta.setName("lblHasta");
|
177 |
lblHasta.setText("_hasta");
|
178 |
jpanel1.add(lblHasta,cc.xy(6,8)); |
179 |
|
180 |
txtHasta.setName("txtHasta");
|
181 |
jpanel1.add(txtHasta,cc.xy(8,8)); |
182 |
|
183 |
btnBuscar.setActionCommand("JButton");
|
184 |
btnBuscar.setName("btnBuscar");
|
185 |
btnBuscar.setText("_buscar");
|
186 |
jpanel1.add(btnBuscar,cc.xy(10,8)); |
187 |
|
188 |
addFillComponents(jpanel1,new int[]{ 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16 },new int[]{ 1,2,3,4,5,6,7,8,9,10,11,12,13 }); |
189 |
return jpanel1;
|
190 |
} |
191 |
|
192 |
/**
|
193 |
* Initializer
|
194 |
*/
|
195 |
protected void initializePanel() |
196 |
{ |
197 |
setLayout(new BorderLayout()); |
198 |
add(createPanel(), BorderLayout.CENTER);
|
199 |
} |
200 |
|
201 |
|
202 |
} |