root / tags / v1_1_Build_1007 / libraries / libCq CMS for java.old / src / org / cresques / ui / NewDialogPanel.java @ 12478
History | View | Annotate | Download (6.24 KB)
1 |
package org.cresques.ui; |
---|---|
2 |
|
3 |
import java.awt.Dimension; |
4 |
import java.awt.FlowLayout; |
5 |
import java.awt.GridBagConstraints; |
6 |
import java.awt.GridBagLayout; |
7 |
|
8 |
import javax.swing.JButton; |
9 |
import javax.swing.JPanel; |
10 |
|
11 |
import org.cresques.i18n.Messages; |
12 |
import org.cresques.ui.raster.IResize; |
13 |
|
14 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
15 |
*
|
16 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
17 |
*
|
18 |
* This program is free software; you can redistribute it and/or
|
19 |
* modify it under the terms of the GNU General Public License
|
20 |
* as published by the Free Software Foundation; either version 2
|
21 |
* of the License, or (at your option) any later version.
|
22 |
*
|
23 |
* This program is distributed in the hope that it will be useful,
|
24 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
25 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
26 |
* GNU General Public License for more details.
|
27 |
*
|
28 |
* You should have received a copy of the GNU General Public License
|
29 |
* along with this program; if not, write to the Free Software
|
30 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
31 |
*
|
32 |
* For more information, contact:
|
33 |
*
|
34 |
* Generalitat Valenciana
|
35 |
* Conselleria d'Infraestructures i Transport
|
36 |
* Av. Blasco Ib??ez, 50
|
37 |
* 46010 VALENCIA
|
38 |
* SPAIN
|
39 |
*
|
40 |
* +34 963862235
|
41 |
* gvsig@gva.es
|
42 |
* www.gvsig.gva.es
|
43 |
*
|
44 |
* or
|
45 |
*
|
46 |
* IVER T.I. S.A
|
47 |
* Salamanca 50
|
48 |
* 46005 Valencia
|
49 |
* Spain
|
50 |
*
|
51 |
* +34 963163400
|
52 |
* dac@iver.es
|
53 |
*/
|
54 |
/* CVS MESSAGES:
|
55 |
*
|
56 |
* $Id: NewDialogPanel.java 12478 2007-07-05 08:28:17Z $
|
57 |
* $Log$
|
58 |
* Revision 1.1.2.1 2006-12-27 08:49:12 maquerol
|
59 |
* Intoducci?n del NewDialogPanel para solucionar problemas con las dimensiones del panel.
|
60 |
*
|
61 |
* Revision 1.1 2006/12/21 12:52:54 maquerol
|
62 |
* Panel NewDialogPanel
|
63 |
*
|
64 |
*
|
65 |
*/
|
66 |
/**
|
67 |
* @author Miguel ?ngel Querol Carratal? <querol_mig@gva.es>
|
68 |
*/
|
69 |
public class NewDialogPanel extends JPanel{ |
70 |
|
71 |
|
72 |
private int wPanel = 300, hPanel = 200; |
73 |
private int wButton = wPanel - 20, hButton = 25; |
74 |
private int wTab = wButton, hTab = hPanel - hButton - 10; |
75 |
private int wContent = wTab - 4, hContent = hTab - 10; |
76 |
private int wButtonContainer = 137, hButtonContainer = 28; |
77 |
|
78 |
|
79 |
private JPanel tabPane = null; |
80 |
private JPanel pButton = null; |
81 |
private JButton cancelButton = null; |
82 |
private JButton acceptButton = null; |
83 |
protected JPanel contentPane = null; |
84 |
private JPanel pButtonContainer = null; |
85 |
|
86 |
|
87 |
|
88 |
/**
|
89 |
* This is the default constructor
|
90 |
*/
|
91 |
public NewDialogPanel(boolean init) { |
92 |
if (init)
|
93 |
initialize(); |
94 |
} |
95 |
|
96 |
public NewDialogPanel(){
|
97 |
super();
|
98 |
initialize(); |
99 |
} |
100 |
|
101 |
/**
|
102 |
* This method initializes this
|
103 |
*
|
104 |
* @return void
|
105 |
*/
|
106 |
private void initialize() { |
107 |
GridBagConstraints gridBagConstraints1 = new GridBagConstraints(); |
108 |
gridBagConstraints1.gridx = 0;
|
109 |
gridBagConstraints1.insets = new java.awt.Insets(5,0,0,0); |
110 |
gridBagConstraints1.gridy = 1;
|
111 |
GridBagConstraints gridBagConstraints = new GridBagConstraints(); |
112 |
gridBagConstraints.gridx = 0;
|
113 |
gridBagConstraints.gridy = 0;
|
114 |
this.setLayout(new GridBagLayout()); |
115 |
this.setSize(300, 200); |
116 |
this.add(getTabPanel(), gridBagConstraints);
|
117 |
this.add(getPButton(), gridBagConstraints1);
|
118 |
} |
119 |
|
120 |
/**
|
121 |
* This method initializes jPanel
|
122 |
*
|
123 |
* @return javax.swing.JPanel
|
124 |
*/
|
125 |
protected JPanel getTabPanel() { |
126 |
if (tabPane == null) { |
127 |
tabPane = new JPanel(); |
128 |
tabPane.setLayout(new FlowLayout()); |
129 |
tabPane.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED)); |
130 |
tabPane.setPreferredSize(new Dimension(wTab, hTab)); |
131 |
tabPane.add(getContentPanel(), null);
|
132 |
} |
133 |
return tabPane;
|
134 |
} |
135 |
|
136 |
|
137 |
/**
|
138 |
* This method initializes jPanel
|
139 |
*
|
140 |
* @return javax.swing.JPanel
|
141 |
*/
|
142 |
protected JPanel getContentPanel() { |
143 |
if (contentPane == null) { |
144 |
contentPane = new JPanel(); |
145 |
contentPane.setPreferredSize(new java.awt.Dimension(wContent,hContent));
|
146 |
} |
147 |
return contentPane;
|
148 |
} |
149 |
|
150 |
|
151 |
/**
|
152 |
* This method initializes jPanel1
|
153 |
*
|
154 |
* @return javax.swing.JPanel
|
155 |
*/
|
156 |
private JPanel getPButton() { |
157 |
if (pButton == null) { |
158 |
FlowLayout flowLayout = new FlowLayout(); |
159 |
flowLayout.setHgap(0);
|
160 |
flowLayout.setAlignment(java.awt.FlowLayout.RIGHT); |
161 |
flowLayout.setVgap(0);
|
162 |
pButton = new JPanel(); |
163 |
pButton.setLayout(flowLayout); |
164 |
pButton.setPreferredSize(new Dimension(wButton, hButton)); |
165 |
//
|
166 |
pButton.add(getPButtonContainer(), null);
|
167 |
//pButton.add(getCancelButton(), null);
|
168 |
} |
169 |
return pButton;
|
170 |
} |
171 |
|
172 |
/**
|
173 |
* This method initializes jButton
|
174 |
*
|
175 |
* @return javax.swing.JButton
|
176 |
*/
|
177 |
public JButton getCancelButton() { |
178 |
if (cancelButton == null) { |
179 |
cancelButton = new JButton("Cancelar"); |
180 |
cancelButton.setText(Messages.getText("Cancelar"));
|
181 |
} |
182 |
return cancelButton;
|
183 |
} |
184 |
|
185 |
/**
|
186 |
* This method initializes jButton1
|
187 |
*
|
188 |
* @return javax.swing.JButton
|
189 |
*/
|
190 |
public JButton getAcceptButton() { |
191 |
if (acceptButton == null) { |
192 |
acceptButton = new JButton("Aceptar"); |
193 |
acceptButton.setText(Messages.getText("Aceptar"));
|
194 |
} |
195 |
return acceptButton;
|
196 |
} |
197 |
|
198 |
public void setComponentSize(int w, int h) { |
199 |
int wPanel = w, hPanel = h;
|
200 |
int wButton = wPanel - 20, hButton = 25; |
201 |
int wTab = wButton, hTab = hPanel - hButton - 10; |
202 |
int wContent = wTab - 4, hContent = hTab - 10; |
203 |
|
204 |
this.setSize(wPanel, hPanel);
|
205 |
getPButton().setPreferredSize(new Dimension(wButton, hButton)); |
206 |
getTabPanel().setPreferredSize(new Dimension(wTab, hTab)); |
207 |
getContentPanel().setPreferredSize(new Dimension(wContent, hContent)); |
208 |
} |
209 |
|
210 |
/**
|
211 |
* This method initializes jPanel
|
212 |
*
|
213 |
* @return javax.swing.JPanel
|
214 |
*/
|
215 |
private JPanel getPButtonContainer() { |
216 |
if (pButtonContainer == null) { |
217 |
GridBagConstraints gridBagConstraints3 = new GridBagConstraints(); |
218 |
gridBagConstraints3.insets = new java.awt.Insets(0,2,0,0); |
219 |
gridBagConstraints3.gridy = 0;
|
220 |
gridBagConstraints3.gridx = 1;
|
221 |
GridBagConstraints gridBagConstraints2 = new GridBagConstraints(); |
222 |
gridBagConstraints2.insets = new java.awt.Insets(0,0,0,2); |
223 |
gridBagConstraints2.gridy = 0;
|
224 |
gridBagConstraints2.gridx = 0;
|
225 |
pButtonContainer = new JPanel(); |
226 |
pButtonContainer.setLayout(new GridBagLayout()); |
227 |
pButtonContainer.setPreferredSize(new Dimension(wButtonContainer, hButtonContainer)); |
228 |
pButtonContainer.add(getAcceptButton(), gridBagConstraints2); |
229 |
pButtonContainer.add(getCancelButton(), gridBagConstraints3); |
230 |
} |
231 |
return pButtonContainer;
|
232 |
} |
233 |
|
234 |
|
235 |
|
236 |
} |