svn-gvsig-desktop / tags / v1_0_2_Build_905 / applications / appgvSIG / src / com / iver / cit / gvsig / gui / utils / FontChooser.java @ 10767
History | View | Annotate | Download (22.9 KB)
1 | 7304 | caballero | /*
|
---|---|---|---|
2 | * Created on 02-jun-2004
|
||
3 | *
|
||
4 | */
|
||
5 | /* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
||
6 | *
|
||
7 | * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
||
8 | *
|
||
9 | * This program is free software; you can redistribute it and/or
|
||
10 | * modify it under the terms of the GNU General Public License
|
||
11 | * as published by the Free Software Foundation; either version 2
|
||
12 | * of the License, or (at your option) any later version.
|
||
13 | *
|
||
14 | * This program is distributed in the hope that it will be useful,
|
||
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
17 | * GNU General Public License for more details.
|
||
18 | *
|
||
19 | * You should have received a copy of the GNU General Public License
|
||
20 | * along with this program; if not, write to the Free Software
|
||
21 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
||
22 | *
|
||
23 | * For more information, contact:
|
||
24 | *
|
||
25 | * Generalitat Valenciana
|
||
26 | * Conselleria d'Infraestructures i Transport
|
||
27 | * Av. Blasco Ib??ez, 50
|
||
28 | * 46010 VALENCIA
|
||
29 | * SPAIN
|
||
30 | *
|
||
31 | * +34 963862235
|
||
32 | * gvsig@gva.es
|
||
33 | * www.gvsig.gva.es
|
||
34 | *
|
||
35 | * or
|
||
36 | *
|
||
37 | * IVER T.I. S.A
|
||
38 | * Salamanca 50
|
||
39 | * 46005 Valencia
|
||
40 | * Spain
|
||
41 | *
|
||
42 | * +34 963163400
|
||
43 | * dac@iver.es
|
||
44 | */
|
||
45 | package com.iver.cit.gvsig.gui.utils; |
||
46 | |||
47 | /*
|
||
48 | 8142 | jaume | * The Unified Mapping Platform (JUMP) is an extensible, interactive GUI
|
49 | 7304 | caballero | * for visualizing and manipulating spatial features with geometry and attributes.
|
50 | *
|
||
51 | * Copyright (C) 2003 Vivid Solutions
|
||
52 | 8142 | jaume | *
|
53 | 7304 | caballero | * This program is free software; you can redistribute it and/or
|
54 | * modify it under the terms of the GNU General Public License
|
||
55 | * as published by the Free Software Foundation; either version 2
|
||
56 | * of the License, or (at your option) any later version.
|
||
57 | 8142 | jaume | *
|
58 | 7304 | caballero | * This program is distributed in the hope that it will be useful,
|
59 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
60 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
61 | * GNU General Public License for more details.
|
||
62 | 8142 | jaume | *
|
63 | 7304 | caballero | * You should have received a copy of the GNU General Public License
|
64 | * along with this program; if not, write to the Free Software
|
||
65 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||
66 | 8142 | jaume | *
|
67 | 7304 | caballero | * For more information, contact:
|
68 | *
|
||
69 | * Vivid Solutions
|
||
70 | * Suite #1A
|
||
71 | * 2328 Government Street
|
||
72 | * Victoria BC V8T 5G5
|
||
73 | * Canada
|
||
74 | *
|
||
75 | * (250)385-6040
|
||
76 | * www.vividsolutions.com
|
||
77 | */
|
||
78 | |||
79 | |||
80 | import java.awt.Font; |
||
81 | import java.awt.GraphicsEnvironment; |
||
82 | import java.awt.GridBagConstraints; |
||
83 | import java.awt.Insets; |
||
84 | import java.awt.event.KeyEvent; |
||
85 | import java.util.StringTokenizer; |
||
86 | |||
87 | import javax.swing.DefaultListModel; |
||
88 | import javax.swing.JList; |
||
89 | import javax.swing.JPanel; |
||
90 | import javax.swing.JScrollPane; |
||
91 | |||
92 | import com.iver.andami.PluginServices; |
||
93 | import com.iver.andami.ui.mdiManager.IWindow; |
||
94 | import com.iver.andami.ui.mdiManager.WindowInfo; |
||
95 | |||
96 | |||
97 | /**
|
||
98 | * Based on FontChooser by Janos Szatmary. Posted on the Sun Java forums.
|
||
99 | *
|
||
100 | * Szatmary, Janos. "A FontChooser Class (source included)." April 2001.
|
||
101 | * Available from http://forum.java.sun.com/thread.jsp?forum=57&thread=124810.
|
||
102 | * Internet; accessed 6 November 2002.
|
||
103 | *
|
||
104 | */
|
||
105 | public class FontChooser extends JPanel implements IWindow{ |
||
106 | private String sampleText = "The quick brown fox jumped over the lazy dog."; |
||
107 | String[] styleList = new String[] { PluginServices.getText(this,"Plain"), |
||
108 | PluginServices.getText(this,"Bold"), PluginServices.getText(this,"Italic") }; |
||
109 | String[] sizeList = new String[] { |
||
110 | "2", "4", "6", "8", "10", "12", "14", "16", "18", "20", "22", "24", |
||
111 | "30", "36", "48", "72" |
||
112 | }; |
||
113 | String currentFont = null; |
||
114 | int currentStyle = -1; |
||
115 | int currentSize = -1; |
||
116 | public boolean ok = false; |
||
117 | |||
118 | // Variables declaration - do not modify
|
||
119 | private javax.swing.JPanel jPanel3;
|
||
120 | private javax.swing.JTextField jFont;
|
||
121 | private javax.swing.JScrollPane jScrollPane1;
|
||
122 | private javax.swing.JList jFontList;
|
||
123 | private javax.swing.JPanel jPanel4;
|
||
124 | private javax.swing.JTextField jStyle;
|
||
125 | private javax.swing.JScrollPane jScrollPane2;
|
||
126 | private javax.swing.JList jStyleList;
|
||
127 | private javax.swing.JPanel jPanel5;
|
||
128 | private javax.swing.JTextField jSize;
|
||
129 | private javax.swing.JScrollPane jScrollPane3;
|
||
130 | private javax.swing.JList jSizeList;
|
||
131 | private javax.swing.JPanel jPanel1;
|
||
132 | private javax.swing.JScrollPane jScrollPane4;
|
||
133 | private javax.swing.JTextArea jSample;
|
||
134 | private javax.swing.JPanel jButtons;
|
||
135 | private javax.swing.JButton jOk;
|
||
136 | private javax.swing.JButton jCancel;
|
||
137 | private javax.swing.JLabel jLabel6;
|
||
138 | private String m_title; |
||
139 | /* ------------------------------------------------------------- */
|
||
140 | private FontChooser() {
|
||
141 | //super(parent, modal);
|
||
142 | jbInit(); |
||
143 | setListValues(jFontList, |
||
144 | GraphicsEnvironment.getLocalGraphicsEnvironment()
|
||
145 | .getAvailableFontFamilyNames()); |
||
146 | setListValues(jStyleList, styleList); |
||
147 | setListValues(jSizeList, sizeList); |
||
148 | setCurrentFont(jSample.getFont()); |
||
149 | // pack();
|
||
150 | } |
||
151 | |||
152 | private FontChooser(Font font) { |
||
153 | this();
|
||
154 | setCurrentFont(font); |
||
155 | } |
||
156 | |||
157 | /* ------------------------------------------------------------- */
|
||
158 | private void setListValues(JList list, String[] values) { |
||
159 | if (list.getModel() instanceof DefaultListModel) { |
||
160 | DefaultListModel model = (DefaultListModel) list.getModel(); |
||
161 | model.removeAllElements(); |
||
162 | |||
163 | for (int j = 0; j < values.length; j++) { |
||
164 | model.addElement(values[j]); |
||
165 | } |
||
166 | } |
||
167 | } |
||
168 | |||
169 | /* ------------------------------------------------------------- */
|
||
170 | private void setSampleFont() { |
||
171 | if ((currentFont != null) && (currentStyle >= 0) && (currentSize > 0)) { |
||
172 | jSample.setFont(new Font(currentFont, currentStyle, currentSize)); |
||
173 | } |
||
174 | } |
||
175 | |||
176 | private String styleToString(int style) { |
||
177 | String str = ""; |
||
178 | |||
179 | if ((style & Font.BOLD) == Font.BOLD) { |
||
180 | if (str.length() > 0) { |
||
181 | str += ",";
|
||
182 | } |
||
183 | |||
184 | str += PluginServices.getText(this,"Bold"); |
||
185 | } |
||
186 | |||
187 | if ((style & Font.ITALIC) == Font.ITALIC) { |
||
188 | if (str.length() > 0) { |
||
189 | str += ",";
|
||
190 | } |
||
191 | |||
192 | str += PluginServices.getText(this,"Italic"); |
||
193 | } |
||
194 | |||
195 | if ((str.length() <= 0) && ((style & Font.PLAIN) == Font.PLAIN)) { |
||
196 | str = PluginServices.getText(this,"Plain"); |
||
197 | } |
||
198 | |||
199 | return str;
|
||
200 | } |
||
201 | |||
202 | /* ------------------------------------------------------------- */
|
||
203 | public Font getCurrentFont() { |
||
204 | return jSample.getFont();
|
||
205 | } |
||
206 | |||
207 | /* ------------------------------------------------------------- */
|
||
208 | public void setCurrentFont(Font font) { |
||
209 | if (font == null) { |
||
210 | font = jSample.getFont(); |
||
211 | } |
||
212 | 8142 | jaume | |
213 | 7304 | caballero | jFont.setText(font.getName()); |
214 | jFontActionPerformed(null);
|
||
215 | |||
216 | jStyle.setText(styleToString(font.getStyle())); |
||
217 | jStyleActionPerformed(null);
|
||
218 | |||
219 | jSize.setText(Integer.toString(font.getSize()));
|
||
220 | jSizeActionPerformed(null);
|
||
221 | } |
||
222 | |||
223 | /* ------------------------------------------------------------- */
|
||
224 | public static Font showDialog(String title, Font font) { |
||
225 | FontChooser dialog = new FontChooser(font);
|
||
226 | PluginServices.getMDIManager().addWindow(dialog); |
||
227 | /*Point p1 = parent.getLocation();
|
||
228 | Dimension d1 = parent.getSize();
|
||
229 | Dimension d2 = dialog.getSize();
|
||
230 | |||
231 | int x = p1.x + ((d1.width - d2.width) / 2);
|
||
232 | int y = p1.y + ((d1.height - d2.height) / 2);
|
||
233 | |||
234 | if (x < 0) {
|
||
235 | x = 0;
|
||
236 | }
|
||
237 | |||
238 | if (y < 0) {
|
||
239 | y = 0;
|
||
240 | }
|
||
241 | */
|
||
242 | if (title != null) { |
||
243 | dialog.m_title=title; |
||
244 | } |
||
245 | |||
246 | // dialog.setLocation(x, y);
|
||
247 | // dialog.setVisible(true);
|
||
248 | 8142 | jaume | |
249 | 7304 | caballero | Font newfont = null; |
250 | |||
251 | if (dialog.ok) {
|
||
252 | newfont = dialog.getCurrentFont(); |
||
253 | } |
||
254 | |||
255 | //dialog.dispose();
|
||
256 | |||
257 | return newfont;
|
||
258 | } |
||
259 | |||
260 | /** This method is called from within the constructor to
|
||
261 | * initialize the form.
|
||
262 | * WARNING: Do NOT modify this code. The content of this
|
||
263 | method is
|
||
264 | * always regenerated by the FormEditor.
|
||
265 | */
|
||
266 | private void jbInit() { |
||
267 | jPanel3 = new javax.swing.JPanel();
|
||
268 | jFont = new javax.swing.JTextField();
|
||
269 | jScrollPane1 = new javax.swing.JScrollPane();
|
||
270 | jFontList = new javax.swing.JList();
|
||
271 | jPanel4 = new javax.swing.JPanel();
|
||
272 | jStyle = new javax.swing.JTextField();
|
||
273 | jScrollPane2 = new javax.swing.JScrollPane();
|
||
274 | jStyleList = new javax.swing.JList();
|
||
275 | jPanel5 = new javax.swing.JPanel();
|
||
276 | jSize = new javax.swing.JTextField();
|
||
277 | jScrollPane3 = new javax.swing.JScrollPane();
|
||
278 | jSizeList = new javax.swing.JList();
|
||
279 | jPanel1 = new javax.swing.JPanel();
|
||
280 | jScrollPane4 = new javax.swing.JScrollPane();
|
||
281 | jScrollPane4.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
|
||
282 | jScrollPane4.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);
|
||
283 | jSample = new javax.swing.JTextArea();
|
||
284 | jSample.setEditable(false);
|
||
285 | jButtons = new javax.swing.JPanel();
|
||
286 | jOk = new javax.swing.JButton();
|
||
287 | jCancel = new javax.swing.JButton();
|
||
288 | jLabel6 = new javax.swing.JLabel();
|
||
289 | setLayout(new java.awt.GridBagLayout());
|
||
290 | |||
291 | java.awt.GridBagConstraints gridBagConstraints1; |
||
292 | //setTitle("Font Chooser");
|
||
293 | /*addWindowListener(new java.awt.event.WindowAdapter() {
|
||
294 | public void windowClosing(java.awt.event.WindowEvent evt) {
|
||
295 | closeDialog(evt);
|
||
296 | }
|
||
297 | });
|
||
298 | */
|
||
299 | jPanel3.setLayout(new java.awt.GridBagLayout());
|
||
300 | |||
301 | java.awt.GridBagConstraints gridBagConstraints2; |
||
302 | jPanel3.setBorder(new javax.swing.border.TitledBorder(
|
||
303 | new javax.swing.border.EtchedBorder(), " "+PluginServices.getText(this,"Font")+" ")); |
||
304 | |||
305 | jFont.setEditable(false);
|
||
306 | jFont.setColumns(24);
|
||
307 | jFont.addActionListener(new java.awt.event.ActionListener() {
|
||
308 | public void actionPerformed(java.awt.event.ActionEvent evt) { |
||
309 | jFontActionPerformed(evt); |
||
310 | } |
||
311 | }); |
||
312 | gridBagConstraints2 = new java.awt.GridBagConstraints();
|
||
313 | gridBagConstraints2.gridwidth = 0;
|
||
314 | gridBagConstraints2.fill = java.awt.GridBagConstraints.HORIZONTAL; |
||
315 | gridBagConstraints2.insets = new java.awt.Insets(0, 3, 0, 3); |
||
316 | gridBagConstraints2.anchor = java.awt.GridBagConstraints.NORTHWEST; |
||
317 | gridBagConstraints2.weightx = 1.0;
|
||
318 | jStyle.setEditable(false);
|
||
319 | jPanel3.add(jFont, gridBagConstraints2); |
||
320 | |||
321 | jFontList.setModel(new DefaultListModel()); |
||
322 | jFontList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); |
||
323 | jFontList.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
|
||
324 | public void valueChanged( |
||
325 | javax.swing.event.ListSelectionEvent evt) { |
||
326 | jFontListValueChanged(evt); |
||
327 | } |
||
328 | }); |
||
329 | jScrollPane1.setViewportView(jFontList); |
||
330 | |||
331 | gridBagConstraints2 = new java.awt.GridBagConstraints();
|
||
332 | gridBagConstraints2.fill = java.awt.GridBagConstraints.BOTH; |
||
333 | gridBagConstraints2.insets = new java.awt.Insets(3, 3, 3, 3); |
||
334 | gridBagConstraints2.anchor = java.awt.GridBagConstraints.NORTHWEST; |
||
335 | gridBagConstraints2.weightx = 1.0;
|
||
336 | gridBagConstraints2.weighty = 1.0;
|
||
337 | jPanel3.add(jScrollPane1, gridBagConstraints2); |
||
338 | |||
339 | gridBagConstraints1 = new java.awt.GridBagConstraints();
|
||
340 | gridBagConstraints1.fill = java.awt.GridBagConstraints.BOTH; |
||
341 | gridBagConstraints1.insets = new java.awt.Insets(5, 5, 0, 0); |
||
342 | gridBagConstraints1.weightx = 0.5;
|
||
343 | gridBagConstraints1.weighty = 1.0;
|
||
344 | add(jPanel3, gridBagConstraints1); |
||
345 | |||
346 | jPanel4.setLayout(new java.awt.GridBagLayout());
|
||
347 | |||
348 | java.awt.GridBagConstraints gridBagConstraints3; |
||
349 | jPanel4.setBorder(new javax.swing.border.TitledBorder(
|
||
350 | new javax.swing.border.EtchedBorder(), " "+PluginServices.getText(this,"Style")+" ")); |
||
351 | |||
352 | jStyle.setColumns(18);
|
||
353 | jStyle.addActionListener(new java.awt.event.ActionListener() {
|
||
354 | public void actionPerformed(java.awt.event.ActionEvent evt) { |
||
355 | jStyleActionPerformed(evt); |
||
356 | } |
||
357 | }); |
||
358 | gridBagConstraints3 = new java.awt.GridBagConstraints();
|
||
359 | gridBagConstraints3.gridwidth = 0;
|
||
360 | gridBagConstraints3.fill = java.awt.GridBagConstraints.HORIZONTAL; |
||
361 | gridBagConstraints3.insets = new java.awt.Insets(0, 3, 0, 3); |
||
362 | gridBagConstraints3.anchor = java.awt.GridBagConstraints.NORTHWEST; |
||
363 | gridBagConstraints3.weightx = 1.0;
|
||
364 | jPanel4.add(jStyle, gridBagConstraints3); |
||
365 | |||
366 | jStyleList.setModel(new DefaultListModel()); |
||
367 | jStyleList.setVisibleRowCount(4);
|
||
368 | jStyleList.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
|
||
369 | public void valueChanged( |
||
370 | javax.swing.event.ListSelectionEvent evt) { |
||
371 | jStyleListValueChanged(evt); |
||
372 | } |
||
373 | }); |
||
374 | jScrollPane2.setViewportView(jStyleList); |
||
375 | |||
376 | gridBagConstraints3 = new java.awt.GridBagConstraints();
|
||
377 | gridBagConstraints3.fill = java.awt.GridBagConstraints.BOTH; |
||
378 | gridBagConstraints3.insets = new java.awt.Insets(3, 3, 3, 3); |
||
379 | gridBagConstraints3.anchor = java.awt.GridBagConstraints.NORTHWEST; |
||
380 | gridBagConstraints3.weightx = 0.5;
|
||
381 | gridBagConstraints3.weighty = 1.0;
|
||
382 | jPanel4.add(jScrollPane2, gridBagConstraints3); |
||
383 | |||
384 | gridBagConstraints1 = new java.awt.GridBagConstraints();
|
||
385 | gridBagConstraints1.fill = java.awt.GridBagConstraints.BOTH; |
||
386 | gridBagConstraints1.insets = new java.awt.Insets(5, 5, 0, 0); |
||
387 | gridBagConstraints1.weightx = 0.375;
|
||
388 | gridBagConstraints1.weighty = 1.0;
|
||
389 | add(jPanel4, gridBagConstraints1); |
||
390 | |||
391 | jPanel5.setLayout(new java.awt.GridBagLayout());
|
||
392 | |||
393 | java.awt.GridBagConstraints gridBagConstraints4; |
||
394 | jPanel5.setBorder(new javax.swing.border.TitledBorder(
|
||
395 | new javax.swing.border.EtchedBorder(), " "+PluginServices.getText(this,"Size")+" ")); |
||
396 | |||
397 | jSize.setColumns(6);
|
||
398 | jSize.addActionListener(new java.awt.event.ActionListener() {
|
||
399 | public void actionPerformed(java.awt.event.ActionEvent evt) { |
||
400 | jSizeActionPerformed(evt); |
||
401 | } |
||
402 | }); |
||
403 | gridBagConstraints4 = new java.awt.GridBagConstraints();
|
||
404 | gridBagConstraints4.gridwidth = 0;
|
||
405 | gridBagConstraints4.fill = java.awt.GridBagConstraints.HORIZONTAL; |
||
406 | gridBagConstraints4.insets = new java.awt.Insets(0, 3, 0, 3); |
||
407 | gridBagConstraints4.anchor = java.awt.GridBagConstraints.NORTHWEST; |
||
408 | gridBagConstraints4.weightx = 1.0;
|
||
409 | jPanel5.add(jSize, gridBagConstraints4); |
||
410 | |||
411 | jSizeList.setModel(new DefaultListModel()); |
||
412 | jSizeList.setVisibleRowCount(4);
|
||
413 | jSizeList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); |
||
414 | jSizeList.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
|
||
415 | public void valueChanged( |
||
416 | javax.swing.event.ListSelectionEvent evt) { |
||
417 | jSizeListValueChanged(evt); |
||
418 | } |
||
419 | }); |
||
420 | jScrollPane3.setViewportView(jSizeList); |
||
421 | |||
422 | gridBagConstraints4 = new java.awt.GridBagConstraints();
|
||
423 | gridBagConstraints4.fill = java.awt.GridBagConstraints.BOTH; |
||
424 | gridBagConstraints4.insets = new java.awt.Insets(3, 3, 3, 3); |
||
425 | gridBagConstraints4.anchor = java.awt.GridBagConstraints.NORTHWEST; |
||
426 | gridBagConstraints4.weightx = 0.25;
|
||
427 | gridBagConstraints4.weighty = 1.0;
|
||
428 | jPanel5.add(jScrollPane3, gridBagConstraints4); |
||
429 | |||
430 | gridBagConstraints1 = new java.awt.GridBagConstraints();
|
||
431 | gridBagConstraints1.gridwidth = 0;
|
||
432 | gridBagConstraints1.fill = java.awt.GridBagConstraints.BOTH; |
||
433 | gridBagConstraints1.insets = new java.awt.Insets(5, 5, 0, 5); |
||
434 | gridBagConstraints1.weightx = 0.125;
|
||
435 | gridBagConstraints1.weighty = 1.0;
|
||
436 | |||
437 | // getContentPane().add(jPanel5, gridBagConstraints1);
|
||
438 | jPanel1.setLayout(new java.awt.GridBagLayout());
|
||
439 | |||
440 | java.awt.GridBagConstraints gridBagConstraints5; |
||
441 | jPanel1.setBorder(new javax.swing.border.TitledBorder(
|
||
442 | new javax.swing.border.EtchedBorder(), " "+PluginServices.getText(this,"Sample")+" ")); |
||
443 | |||
444 | jSample.setWrapStyleWord(true);
|
||
445 | jSample.setLineWrap(true);
|
||
446 | jSample.setColumns(20);
|
||
447 | jSample.setRows(3);
|
||
448 | jSample.setText(sampleText); |
||
449 | jScrollPane4.setViewportView(jSample); |
||
450 | |||
451 | gridBagConstraints5 = new java.awt.GridBagConstraints();
|
||
452 | gridBagConstraints5.fill = java.awt.GridBagConstraints.BOTH; |
||
453 | gridBagConstraints5.insets = new java.awt.Insets(0, 3, 3, 3); |
||
454 | gridBagConstraints5.weightx = 1.0;
|
||
455 | gridBagConstraints5.weighty = 1.0;
|
||
456 | jPanel1.add(jScrollPane4, gridBagConstraints5); |
||
457 | |||
458 | gridBagConstraints1 = new java.awt.GridBagConstraints();
|
||
459 | gridBagConstraints1.gridwidth = 0;
|
||
460 | gridBagConstraints1.fill = java.awt.GridBagConstraints.BOTH; |
||
461 | gridBagConstraints1.insets = new java.awt.Insets(0, 5, 0, 5); |
||
462 | gridBagConstraints1.anchor = java.awt.GridBagConstraints.NORTHWEST; |
||
463 | gridBagConstraints1.weightx = 1.0;
|
||
464 | add(jPanel1, |
||
465 | new GridBagConstraints(0, 1, 3, 1, 0.0, 0.0, |
||
466 | GridBagConstraints.CENTER, GridBagConstraints.BOTH, |
||
467 | new Insets(0, 3, 3, 3), 0, 0)); |
||
468 | |||
469 | jButtons.setLayout(new java.awt.GridBagLayout());
|
||
470 | |||
471 | jOk.setMnemonic(KeyEvent.VK_O);
|
||
472 | jOk.setText(PluginServices.getText(this,"Aceptar")); |
||
473 | jOk.setRequestFocusEnabled(false);
|
||
474 | jOk.addActionListener(new java.awt.event.ActionListener() {
|
||
475 | public void actionPerformed(java.awt.event.ActionEvent evt) { |
||
476 | jOkActionPerformed(evt); |
||
477 | } |
||
478 | }); |
||
479 | jButtons.add(jOk, |
||
480 | new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, |
||
481 | GridBagConstraints.WEST, GridBagConstraints.NONE, |
||
482 | new Insets(5, 5, 5, 0), 0, 0)); |
||
483 | |||
484 | jCancel.setMnemonic(KeyEvent.VK_C);
|
||
485 | jCancel.setText(PluginServices.getText(this,"Cancelar")); |
||
486 | jCancel.setRequestFocusEnabled(false);
|
||
487 | jCancel.addActionListener(new java.awt.event.ActionListener() {
|
||
488 | public void actionPerformed(java.awt.event.ActionEvent evt) { |
||
489 | jCancelActionPerformed(evt); |
||
490 | } |
||
491 | }); |
||
492 | |||
493 | jButtons.add(jCancel, |
||
494 | new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, |
||
495 | GridBagConstraints.WEST, GridBagConstraints.NONE, |
||
496 | new Insets(5, 5, 5, 5), 0, 0)); |
||
497 | |||
498 | gridBagConstraints1 = new java.awt.GridBagConstraints();
|
||
499 | gridBagConstraints1.gridwidth = 0;
|
||
500 | gridBagConstraints1.anchor = java.awt.GridBagConstraints.SOUTHWEST; |
||
501 | gridBagConstraints1.weightx = 1.0;
|
||
502 | add(jButtons, |
||
503 | new GridBagConstraints(0, 2, 3, 1, 0.0, 0.0, |
||
504 | GridBagConstraints.SOUTHWEST, GridBagConstraints.NONE, |
||
505 | new Insets(0, 0, 0, 0), 0, 0)); |
||
506 | } |
||
507 | |||
508 | private void jCancelActionPerformed(java.awt.event.ActionEvent evt) { |
||
509 | // Add your handling code here:
|
||
510 | PluginServices.getMDIManager().closeWindow(FontChooser.this); |
||
511 | } |
||
512 | |||
513 | private void jOkActionPerformed(java.awt.event.ActionEvent evt) { |
||
514 | // Add your handling code here:
|
||
515 | ok = true;
|
||
516 | PluginServices.getMDIManager().closeWindow(FontChooser.this); |
||
517 | } |
||
518 | |||
519 | private void jSizeActionPerformed(java.awt.event.ActionEvent evt) { |
||
520 | // Add your handling code here:
|
||
521 | int size = 0; |
||
522 | |||
523 | try {
|
||
524 | size = Integer.parseInt(jSize.getText());
|
||
525 | } catch (Exception e) { |
||
526 | } |
||
527 | |||
528 | if (size > 0) { |
||
529 | currentSize = size; |
||
530 | setSampleFont(); |
||
531 | } |
||
532 | } |
||
533 | |||
534 | private void jStyleActionPerformed(java.awt.event.ActionEvent evt) { |
||
535 | // Add your handling code here:
|
||
536 | StringTokenizer st = new StringTokenizer(jStyle.getText(), ","); |
||
537 | int style = 0; |
||
538 | |||
539 | while (st.hasMoreTokens()) {
|
||
540 | String str = st.nextToken().trim();
|
||
541 | |||
542 | if (str.equalsIgnoreCase(PluginServices.getText(this,"Plain"))) { |
||
543 | style |= Font.PLAIN;
|
||
544 | } else if (str.equalsIgnoreCase(PluginServices.getText(this,"Bold"))) { |
||
545 | style |= Font.BOLD;
|
||
546 | } else if (str.equalsIgnoreCase(PluginServices.getText(this,"Italic"))) { |
||
547 | style |= Font.ITALIC;
|
||
548 | } |
||
549 | } |
||
550 | |||
551 | if (style >= 0) { |
||
552 | currentStyle = style; |
||
553 | setSampleFont(); |
||
554 | } |
||
555 | } |
||
556 | |||
557 | private void jFontActionPerformed(java.awt.event.ActionEvent evt) { |
||
558 | // Add your handling code here:
|
||
559 | DefaultListModel model = (DefaultListModel) jFontList.getModel(); |
||
560 | |||
561 | if (model.indexOf(jFont.getText()) >= 0) { |
||
562 | currentFont = jFont.getText(); |
||
563 | setSampleFont(); |
||
564 | } |
||
565 | } |
||
566 | |||
567 | private void jStyleListValueChanged( |
||
568 | javax.swing.event.ListSelectionEvent evt) { |
||
569 | // Add your handling code here:
|
||
570 | String str = new String(); |
||
571 | Object[] values = jStyleList.getSelectedValues(); |
||
572 | |||
573 | if (values.length > 0) { |
||
574 | int j;
|
||
575 | |||
576 | for (j = 0; j < values.length; j++) { |
||
577 | String s = (String) values[j]; |
||
578 | |||
579 | if (s.equalsIgnoreCase(PluginServices.getText(this,"Plain"))) { |
||
580 | str = PluginServices.getText(this,"Plain"); |
||
581 | |||
582 | break;
|
||
583 | } |
||
584 | |||
585 | if (str.length() > 0) { |
||
586 | str += ",";
|
||
587 | } |
||
588 | |||
589 | str += (String) values[j];
|
||
590 | } |
||
591 | } else {
|
||
592 | str = styleToString(currentStyle); |
||
593 | } |
||
594 | |||
595 | jStyle.setText(str); |
||
596 | jStyleActionPerformed(null);
|
||
597 | } |
||
598 | |||
599 | private void jSizeListValueChanged(javax.swing.event.ListSelectionEvent evt) { |
||
600 | // Add your handling code here:
|
||
601 | String str = (String) jSizeList.getSelectedValue(); |
||
602 | |||
603 | if ((str == null) || (str.length() <= 0)) { |
||
604 | str = Integer.toString(currentSize);
|
||
605 | } |
||
606 | |||
607 | jSize.setText(str); |
||
608 | jSizeActionPerformed(null);
|
||
609 | } |
||
610 | |||
611 | private void jFontListValueChanged(javax.swing.event.ListSelectionEvent evt) { |
||
612 | // Add your handling code here:
|
||
613 | String str = (String) jFontList.getSelectedValue(); |
||
614 | |||
615 | if ((str == null) || (str.length() <= 0)) { |
||
616 | str = currentFont; |
||
617 | } |
||
618 | |||
619 | jFont.setText(str); |
||
620 | jFontActionPerformed(null);
|
||
621 | } |
||
622 | |||
623 | |||
624 | 8142 | jaume | |
625 | 7304 | caballero | /* (non-Javadoc)
|
626 | * @see com.iver.mdiApp.ui.MDIManager.View#getViewInfo()
|
||
627 | */
|
||
628 | public WindowInfo getWindowInfo() {
|
||
629 | WindowInfo m_viewinfo=new WindowInfo(WindowInfo.MODALDIALOG);
|
||
630 | m_viewinfo.setWidth(350);
|
||
631 | m_viewinfo.setHeight(250);
|
||
632 | //vi.setResizable(false);
|
||
633 | m_viewinfo.setTitle(PluginServices.getText(this,"Elegir_Fuente")); |
||
634 | 8142 | jaume | |
635 | 7304 | caballero | return m_viewinfo;
|
636 | } |
||
637 | |||
638 | /**
|
||
639 | * @see com.iver.mdiApp.ui.MDIManager.IWindow#windowActivated()
|
||
640 | */
|
||
641 | public void viewActivated() { |
||
642 | } |
||
643 | |||
644 | // End of variables declaration
|
||
645 | } |