svn-gvsig-desktop / tags / v1_0_2_RELEASE / libraries / libCq CMS for java.old / src / org / cresques / ui / DefaultDialogPanel.java @ 11432
History | View | Annotate | Download (8.13 KB)
1 | 2809 | nacho | /*
|
---|---|---|---|
2 | * Cresques Mapping Suite. Graphic Library for constructing mapping applications.
|
||
3 | *
|
||
4 | * Copyright (C) 2004-5.
|
||
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 2
|
||
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
||
19 | *
|
||
20 | * For more information, contact:
|
||
21 | *
|
||
22 | * cresques@gmail.com
|
||
23 | */
|
||
24 | package org.cresques.ui; |
||
25 | |||
26 | 6830 | maquerol | import java.awt.FlowLayout; |
27 | 5001 | nacho | import java.awt.GridBagConstraints; |
28 | import java.awt.GridBagLayout; |
||
29 | import java.awt.event.ComponentEvent; |
||
30 | import java.awt.event.ComponentListener; |
||
31 | 2809 | nacho | |
32 | import javax.swing.JButton; |
||
33 | import javax.swing.JPanel; |
||
34 | 6830 | maquerol | import javax.swing.event.ChangeEvent; |
35 | import javax.swing.event.ChangeListener; |
||
36 | 2809 | nacho | |
37 | 8765 | jjdelcerro | import org.cresques.i18n.Messages; |
38 | 2809 | nacho | |
39 | 8765 | jjdelcerro | |
40 | 2809 | nacho | /**
|
41 | * @author Luis W. Sevilla (sevilla_lui@gva.es)
|
||
42 | */
|
||
43 | 5001 | nacho | public class DefaultDialogPanel extends JPanel implements ComponentListener{ |
44 | 2809 | nacho | final private static long serialVersionUID = -3370601314380922368L; |
45 | protected JPanel contentPane = null; |
||
46 | private JPanel tabPane = null; |
||
47 | 6830 | maquerol | protected JPanel buttonPane = null; |
48 | 2809 | nacho | private JButton acceptButton = null; |
49 | private JButton cancelButton = null; |
||
50 | private JButton applyButton = null; |
||
51 | 5001 | nacho | private int flag = 0; |
52 | protected int cWidth = 0, difWidth = 0; |
||
53 | protected int cHeight = 0, difHeight = 0; |
||
54 | 6830 | maquerol | protected JPanel pButton = null; |
55 | 2809 | nacho | |
56 | /**
|
||
57 | * Constructor
|
||
58 | 4405 | nacho | * @param init
|
59 | 2809 | nacho | */
|
60 | 4405 | nacho | public DefaultDialogPanel(boolean init){ |
61 | if(init)
|
||
62 | initialize(); |
||
63 | } |
||
64 | 8765 | jjdelcerro | |
65 | 4405 | nacho | /**
|
66 | * Constructor
|
||
67 | */
|
||
68 | 2809 | nacho | public DefaultDialogPanel() {
|
69 | super();
|
||
70 | 4405 | nacho | this.initialize();
|
71 | 2809 | nacho | } |
72 | |||
73 | /**
|
||
74 | * This method initializes this
|
||
75 | *
|
||
76 | * @return void
|
||
77 | */
|
||
78 | 4405 | nacho | public void initialize() { |
79 | 2809 | nacho | //setBounds(0,0,321,230);
|
80 | //javax.swing.BoxLayout(jContentPane, javax.swing.BoxLayout.Y_AXIS);
|
||
81 | //jContentPane.setLayout(new java.awt.GridLayout(2,1));
|
||
82 | 6830 | maquerol | GridBagConstraints gridBagConstraints11 = new GridBagConstraints(); |
83 | gridBagConstraints11.gridx = 0;
|
||
84 | gridBagConstraints11.insets = new java.awt.Insets(4,0,0,0); |
||
85 | gridBagConstraints11.gridy = 1;
|
||
86 | 5001 | nacho | GridBagConstraints gridBagConstraints = new GridBagConstraints(); |
87 | gridBagConstraints.insets = new java.awt.Insets(5,0,2,0); |
||
88 | gridBagConstraints.gridy = 0;
|
||
89 | gridBagConstraints.gridx = 0;
|
||
90 | setLayout(new GridBagLayout()); |
||
91 | 2809 | nacho | setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5)); |
92 | |||
93 | //jContentPane.setSize(30, 24);
|
||
94 | this.setPreferredSize(new java.awt.Dimension(320, 165)); |
||
95 | 5001 | nacho | this.add(getTabPanel(), gridBagConstraints);
|
96 | 6830 | maquerol | this.add(getPButton(), gridBagConstraints11);
|
97 | 5001 | nacho | this.addComponentListener(this); |
98 | 8765 | jjdelcerro | |
99 | 2809 | nacho | } |
100 | |||
101 | /**
|
||
102 | * Obtiene el panel general
|
||
103 | * @return
|
||
104 | */
|
||
105 | protected JPanel getContentPanel() { |
||
106 | if (contentPane == null) { |
||
107 | contentPane = new JPanel(); |
||
108 | 5001 | nacho | contentPane.setLayout(new GridBagLayout()); |
109 | contentPane.setBounds(6, 200, 310, 125); |
||
110 | 2809 | nacho | contentPane.setPreferredSize(new java.awt.Dimension(310, 100)); |
111 | } |
||
112 | |||
113 | return contentPane;
|
||
114 | } |
||
115 | |||
116 | 5001 | nacho | public JPanel getTabPanel() { |
117 | 2809 | nacho | if (tabPane == null) { |
118 | 5001 | nacho | GridBagConstraints gridBagConstraints2 = new GridBagConstraints(); |
119 | gridBagConstraints2.insets = new java.awt.Insets(5,0,0,0); |
||
120 | gridBagConstraints2.gridy = 0;
|
||
121 | gridBagConstraints2.gridx = 0;
|
||
122 | 2809 | nacho | tabPane = new JPanel(); |
123 | 5001 | nacho | tabPane.setLayout(new GridBagLayout()); |
124 | 8765 | jjdelcerro | |
125 | |||
126 | 2809 | nacho | //tabPane.setBounds(6, 7, 309, 189);
|
127 | tabPane.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.SoftBevelBorder.RAISED));
|
||
128 | 5001 | nacho | tabPane.add(getContentPanel(), gridBagConstraints2); |
129 | 2809 | nacho | } |
130 | |||
131 | return tabPane;
|
||
132 | } |
||
133 | |||
134 | /**
|
||
135 | 8765 | jjdelcerro | * This method initializes jPanel
|
136 | *
|
||
137 | * @return javax.swing.JPanel
|
||
138 | 6830 | maquerol | */
|
139 | private JPanel getPButton() { |
||
140 | if (pButton == null) { |
||
141 | FlowLayout flowLayout1 = new FlowLayout(); |
||
142 | flowLayout1.setAlignment(java.awt.FlowLayout.RIGHT); |
||
143 | flowLayout1.setHgap(0);
|
||
144 | flowLayout1.setVgap(0);
|
||
145 | pButton = new JPanel(); |
||
146 | pButton.setPreferredSize(new java.awt.Dimension(320,25)); |
||
147 | pButton.setLayout(flowLayout1); |
||
148 | pButton.add(getButtonPanel(), null);
|
||
149 | } |
||
150 | return pButton;
|
||
151 | } |
||
152 | 8765 | jjdelcerro | |
153 | |||
154 | 6830 | maquerol | /**
|
155 | 8765 | jjdelcerro | * Obtiene el panel que contiene los botones de Aceptar, Cancelar y Aplicar
|
156 | 2809 | nacho | * @return
|
157 | */
|
||
158 | protected JPanel getButtonPanel() { |
||
159 | if (buttonPane == null) { |
||
160 | 5001 | nacho | GridBagConstraints gridBagConstraints4 = new GridBagConstraints(); |
161 | 6830 | maquerol | gridBagConstraints4.gridx = 2;
|
162 | gridBagConstraints4.insets = new java.awt.Insets(0,3,0,0); |
||
163 | 5001 | nacho | gridBagConstraints4.gridy = 0;
|
164 | GridBagConstraints gridBagConstraints3 = new GridBagConstraints(); |
||
165 | 6830 | maquerol | gridBagConstraints3.gridx = 1;
|
166 | gridBagConstraints3.insets = new java.awt.Insets(0,3,0,3); |
||
167 | 5001 | nacho | gridBagConstraints3.gridy = 0;
|
168 | 6830 | maquerol | GridBagConstraints gridBagConstraints1 = new GridBagConstraints(); |
169 | gridBagConstraints1.insets = new java.awt.Insets(0,0,0,3); |
||
170 | gridBagConstraints1.gridy = 0;
|
||
171 | gridBagConstraints1.gridx = 0;
|
||
172 | 2809 | nacho | buttonPane = new JPanel(); |
173 | 5001 | nacho | buttonPane.setLayout(new GridBagLayout()); |
174 | 6830 | maquerol | buttonPane.add(getAcceptButton(), gridBagConstraints1); |
175 | buttonPane.add(getCancelButton(), gridBagConstraints3); |
||
176 | buttonPane.add(getApplyButton(), gridBagConstraints4); |
||
177 | 2809 | nacho | } |
178 | |||
179 | return buttonPane;
|
||
180 | } |
||
181 | |||
182 | /**
|
||
183 | * This method initializes Accept button
|
||
184 | *
|
||
185 | * @return javax.swing.JButton
|
||
186 | */
|
||
187 | public JButton getAcceptButton() { |
||
188 | if (acceptButton == null) { |
||
189 | acceptButton = new JButton("Aceptar"); |
||
190 | 8765 | jjdelcerro | acceptButton.setText(Messages.getText("Aceptar"));
|
191 | 2809 | nacho | } |
192 | |||
193 | return acceptButton;
|
||
194 | } |
||
195 | |||
196 | /**
|
||
197 | * This method initializes Cancel Button
|
||
198 | *
|
||
199 | * @return javax.swing.JButton
|
||
200 | */
|
||
201 | public JButton getCancelButton() { |
||
202 | if (cancelButton == null) { |
||
203 | cancelButton = new JButton("Cancelar"); |
||
204 | 8765 | jjdelcerro | cancelButton.setText(Messages.getText("Cancelar"));
|
205 | 2809 | nacho | } |
206 | |||
207 | return cancelButton;
|
||
208 | } |
||
209 | |||
210 | /**
|
||
211 | * This method initializes Apply Button
|
||
212 | *
|
||
213 | * @return javax.swing.JButton
|
||
214 | */
|
||
215 | public JButton getApplyButton() { |
||
216 | if (applyButton == null) { |
||
217 | 8765 | jjdelcerro | applyButton = new JButton(Messages.getText("Aplicar")); |
218 | 2809 | nacho | } |
219 | |||
220 | return applyButton;
|
||
221 | } |
||
222 | 5001 | nacho | |
223 | public void componentHidden(ComponentEvent e) { |
||
224 | // TODO Auto-generated method stub
|
||
225 | 8765 | jjdelcerro | |
226 | 5001 | nacho | } |
227 | |||
228 | public void componentMoved(ComponentEvent e) { |
||
229 | // TODO Auto-generated method stub
|
||
230 | 8765 | jjdelcerro | |
231 | 5001 | nacho | } |
232 | |||
233 | public void componentResized(ComponentEvent e) { |
||
234 | if(e.getSource() == this) |
||
235 | this.resizeWindow();
|
||
236 | } |
||
237 | |||
238 | public void resizeWindow(){ |
||
239 | if (flag == 0){ |
||
240 | cWidth = this.getSize().width;
|
||
241 | cHeight = this.getSize().height;
|
||
242 | flag++; |
||
243 | } |
||
244 | 8765 | jjdelcerro | |
245 | 5001 | nacho | int nWidth = getWidth();
|
246 | int nHeight = getHeight();
|
||
247 | difWidth = nWidth - cWidth; |
||
248 | difHeight = nHeight - cHeight; |
||
249 | this.tabPane.setSize(this.tabPane.getSize().width + difWidth, this.tabPane.getSize().height + difHeight); |
||
250 | this.tabPane.setLocation(this.tabPane.getLocation().x - difWidth/2, this.tabPane.getLocation().y - difHeight/2); |
||
251 | 8765 | jjdelcerro | |
252 | 5001 | nacho | this.contentPane.setSize(this.contentPane.getSize().width + difWidth, this.contentPane.getSize().height + difHeight); |
253 | 6830 | maquerol | //this.pButton.setSize(this.getPButton().getWidth() + difWidth/2, 25);
|
254 | //this.buttonPane.setLocation(this.buttonPane.getLocation().x + difWidth/2, this.buttonPane.getLocation().y + difHeight/2);
|
||
255 | this.pButton.setLocation(this.pButton.getLocation().x + difWidth/2, this.pButton.getLocation().y + difHeight/2); |
||
256 | 8765 | jjdelcerro | |
257 | 5001 | nacho | } |
258 | 8765 | jjdelcerro | |
259 | 5001 | nacho | public void componentShown(ComponentEvent e) { |
260 | // TODO Auto-generated method stub
|
||
261 | 8765 | jjdelcerro | |
262 | 5001 | nacho | } |
263 | 6830 | maquerol | |
264 | 8765 | jjdelcerro | |
265 | 5001 | nacho | } // @jve:decl-index=0:visual-constraint="12,13" |