001: /*
002: * Copyright (C) 2005 - 2008 JasperSoft Corporation. All rights reserved.
003: * http://www.jaspersoft.com.
004: *
005: * Unless you have purchased a commercial license agreement from JasperSoft,
006: * the following license terms apply:
007: *
008: * This program is free software; you can redistribute it and/or modify
009: * it under the terms of the GNU General Public License version 2 as published by
010: * the Free Software Foundation.
011: *
012: * This program is distributed WITHOUT ANY WARRANTY; and without the
013: * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
014: * See the GNU General Public License for more details.
015: *
016: * You should have received a copy of the GNU General Public License
017: * along with this program; if not, see http://www.gnu.org/licenses/gpl.txt
018: * or write to:
019: *
020: * Free Software Foundation, Inc.,
021: * 59 Temple Place - Suite 330,
022: * Boston, MA USA 02111-1307
023: *
024: *
025: *
026: *
027: * BoxPanel.java
028: *
029: * Created on 29 novembre 2004, 18.32
030: *
031: */
032:
033: package it.businesslogic.ireport.gui.box;
034:
035: import it.businesslogic.ireport.gui.sheet.Tag;
036: import it.businesslogic.ireport.util.Misc;
037: import java.awt.event.ActionEvent;
038: import javax.swing.SpinnerNumberModel;
039: import javax.swing.event.*;
040: import it.businesslogic.ireport.*;
041: import it.businesslogic.ireport.gui.sheet.HexColorChooserPanel;
042: import it.businesslogic.ireport.util.I18n;
043: import java.awt.BorderLayout;
044: import java.awt.event.ActionListener;
045:
046: /**
047: *
048: * @author Administrator
049: */
050: public class BoxPanel extends javax.swing.JPanel implements
051: ActionListener {
052:
053: private boolean init = false;
054:
055: SampleBoxPanel samplePanel = null;
056: BoxBorderEditorPanel borderEditorPanel = null;
057: private Box box = null;
058:
059: /** Creates new form BorderPanel */
060: public BoxPanel() {
061: initComponents();
062:
063: jPanel1.setVisible(false);
064:
065: borderEditorPanel = new BoxBorderEditorPanel();
066: borderEditorPanel.addActionPerformedListener(this );
067: jPanelBorderEditorContainer.add(borderEditorPanel,
068: BorderLayout.CENTER);
069:
070: applyI18n();
071:
072: samplePanel = new SampleBoxPanel();
073: init = true;
074:
075: jComboBoxTop.addItem(new Tag("None",
076: it.businesslogic.ireport.util.I18n.getString(
077: "lineType.None", "None")));
078: jComboBoxTop.addItem(new Tag("Thin",
079: it.businesslogic.ireport.util.I18n.getString(
080: "lineType.Thin", "Thin")));
081: jComboBoxTop.addItem(new Tag("1Point",
082: it.businesslogic.ireport.util.I18n.getString(
083: "lineType.1Point", "1Point")));
084: jComboBoxTop.addItem(new Tag("2Point",
085: it.businesslogic.ireport.util.I18n.getString(
086: "lineType.2Point", "2Point")));
087: jComboBoxTop.addItem(new Tag("4Point",
088: it.businesslogic.ireport.util.I18n.getString(
089: "lineType.4Point", "4Point")));
090: jComboBoxTop.addItem(new Tag("Dotted",
091: it.businesslogic.ireport.util.I18n.getString(
092: "lineType.Dotted", "Dotted")));
093: jComboBoxTop.setSelectedIndex(0);
094:
095: jComboBoxLeft.addItem(new Tag("None",
096: it.businesslogic.ireport.util.I18n.getString(
097: "lineType.None", "None")));
098: jComboBoxLeft.addItem(new Tag("Thin",
099: it.businesslogic.ireport.util.I18n.getString(
100: "lineType.Thin", "Thin")));
101: jComboBoxLeft.addItem(new Tag("1Point",
102: it.businesslogic.ireport.util.I18n.getString(
103: "lineType.1Point", "1Point")));
104: jComboBoxLeft.addItem(new Tag("2Point",
105: it.businesslogic.ireport.util.I18n.getString(
106: "lineType.2Point", "2Point")));
107: jComboBoxLeft.addItem(new Tag("4Point",
108: it.businesslogic.ireport.util.I18n.getString(
109: "lineType.4Point", "4Point")));
110: jComboBoxLeft.addItem(new Tag("Dotted",
111: it.businesslogic.ireport.util.I18n.getString(
112: "lineType.Dotted", "Dotted")));
113: jComboBoxLeft.setSelectedIndex(0);
114:
115: jComboBoxRight.addItem(new Tag("None",
116: it.businesslogic.ireport.util.I18n.getString(
117: "lineType.None", "None")));
118: jComboBoxRight.addItem(new Tag("Thin",
119: it.businesslogic.ireport.util.I18n.getString(
120: "lineType.Thin", "Thin")));
121: jComboBoxRight.addItem(new Tag("1Point",
122: it.businesslogic.ireport.util.I18n.getString(
123: "lineType.1Point", "1Point")));
124: jComboBoxRight.addItem(new Tag("2Point",
125: it.businesslogic.ireport.util.I18n.getString(
126: "lineType.2Point", "2Point")));
127: jComboBoxRight.addItem(new Tag("4Point",
128: it.businesslogic.ireport.util.I18n.getString(
129: "lineType.4Point", "4Point")));
130: jComboBoxRight.addItem(new Tag("Dotted",
131: it.businesslogic.ireport.util.I18n.getString(
132: "lineType.Dotted", "Dotted")));
133: jComboBoxRight.setSelectedIndex(0);
134:
135: jComboBoxBottom.addItem(new Tag("None",
136: it.businesslogic.ireport.util.I18n.getString(
137: "lineType.None", "None")));
138: jComboBoxBottom.addItem(new Tag("Thin",
139: it.businesslogic.ireport.util.I18n.getString(
140: "lineType.Thin", "Thin")));
141: jComboBoxBottom.addItem(new Tag("1Point",
142: it.businesslogic.ireport.util.I18n.getString(
143: "lineType.1Point", "1Point")));
144: jComboBoxBottom.addItem(new Tag("2Point",
145: it.businesslogic.ireport.util.I18n.getString(
146: "lineType.2Point", "2Point")));
147: jComboBoxBottom.addItem(new Tag("4Point",
148: it.businesslogic.ireport.util.I18n.getString(
149: "lineType.4Point", "4Point")));
150: jComboBoxBottom.addItem(new Tag("Dotted",
151: it.businesslogic.ireport.util.I18n.getString(
152: "lineType.Dotted", "Dotted")));
153: jComboBoxBottom.setSelectedIndex(0);
154:
155: SpinnerNumberModel snmTop = new SpinnerNumberModel(0, 0, 10000,
156: 1);
157: jSpinnerTop.setModel(snmTop);
158: snmTop.addChangeListener(new ChangeListener() {
159: public void stateChanged(ChangeEvent evt) {
160: jSpinnerTopStateChanged(evt);
161: }
162: });
163:
164: SpinnerNumberModel snmBottom = new SpinnerNumberModel(0, 0,
165: 10000, 1);
166: jSpinnerBottom.setModel(snmBottom);
167: snmBottom.addChangeListener(new ChangeListener() {
168: public void stateChanged(ChangeEvent evt) {
169: jSpinnerBottomStateChanged(evt);
170: }
171: });
172:
173: SpinnerNumberModel snmRight = new SpinnerNumberModel(0, 0,
174: 10000, 1);
175: jSpinnerRight.setModel(snmRight);
176: snmRight.addChangeListener(new ChangeListener() {
177: public void stateChanged(ChangeEvent evt) {
178: jSpinnerRightStateChanged(evt);
179: }
180: });
181:
182: SpinnerNumberModel snmLeft = new SpinnerNumberModel(0, 0,
183: 10000, 1);
184: jSpinnerLeft.setModel(snmLeft);
185: snmLeft.addChangeListener(new ChangeListener() {
186: public void stateChanged(ChangeEvent evt) {
187: jSpinnerLeftStateChanged(evt);
188: }
189: });
190:
191: java.awt.GridBagConstraints gridBagConstraints = new java.awt.GridBagConstraints();
192: gridBagConstraints.gridx = 0;
193: gridBagConstraints.gridy = 0;
194: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
195: gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 0);
196: gridBagConstraints.weightx = 1.0;
197: gridBagConstraints.weighty = 1.0;
198: gridBagConstraints.fill = gridBagConstraints.BOTH;
199: jPanel3.add(samplePanel, gridBagConstraints);
200:
201: box = new Box();
202: init = false;
203: }
204:
205: private void jSpinnerTopStateChanged(ChangeEvent evt) {
206: box
207: .setTopPadding(Integer.parseInt(jSpinnerTop.getValue()
208: + ""));
209: fireActionListenerActionPerformed(new java.awt.event.ActionEvent(
210: this , 0, "TopPadding"));
211: }
212:
213: private void jSpinnerLeftStateChanged(ChangeEvent evt) {
214: box.setLeftPadding(Integer.parseInt(jSpinnerLeft.getValue()
215: + ""));
216: fireActionListenerActionPerformed(new java.awt.event.ActionEvent(
217: this , 0, "LeftPadding"));
218: }
219:
220: private void jSpinnerRightStateChanged(ChangeEvent evt) {
221: box.setRightPadding(Integer.parseInt(jSpinnerRight.getValue()
222: + ""));
223: fireActionListenerActionPerformed(new java.awt.event.ActionEvent(
224: this , 0, "RightPadding"));
225: }
226:
227: private void jSpinnerBottomStateChanged(ChangeEvent evt) {
228: box.setBottomPadding(Integer.parseInt(jSpinnerBottom.getValue()
229: + ""));
230: fireActionListenerActionPerformed(new java.awt.event.ActionEvent(
231: this , 0, "BottomPadding"));
232: }
233:
234: /** This method is called from within the constructor to
235: * initialize the form.
236: * WARNING: Do NOT modify this code. The content of this method is
237: * always regenerated by the Form Editor.
238: */
239: // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
240: private void initComponents() {
241: java.awt.GridBagConstraints gridBagConstraints;
242:
243: jPanel2 = new javax.swing.JPanel();
244: jLabel3 = new javax.swing.JLabel();
245: jSpinnerLeft = new javax.swing.JSpinner();
246: jLabel4 = new javax.swing.JLabel();
247: jSpinnerTop = new javax.swing.JSpinner();
248: jLabel5 = new javax.swing.JLabel();
249: jSpinnerRight = new javax.swing.JSpinner();
250: jLabel6 = new javax.swing.JLabel();
251: jSpinnerBottom = new javax.swing.JSpinner();
252: jPanel1 = new javax.swing.JPanel();
253: jPanel3 = new javax.swing.JPanel();
254: jComboBoxTop = new javax.swing.JComboBox();
255: jButtonBoxColorTop = new javax.swing.JButton();
256: jButtonBoxColorLeft = new javax.swing.JButton();
257: jComboBoxLeft = new javax.swing.JComboBox();
258: jButtonBoxColorBottom = new javax.swing.JButton();
259: jButtonBoxColorRight = new javax.swing.JButton();
260: jComboBoxRight = new javax.swing.JComboBox();
261: jComboBoxBottom = new javax.swing.JComboBox();
262: jPanelBorderEditorContainer = new javax.swing.JPanel();
263:
264: setMinimumSize(new java.awt.Dimension(309, 80));
265: setLayout(new java.awt.GridBagLayout());
266:
267: jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(
268: javax.swing.BorderFactory.createEtchedBorder(),
269: "Padding"));
270: jPanel2.setLayout(new java.awt.GridBagLayout());
271:
272: jLabel3.setText("Left");
273: gridBagConstraints = new java.awt.GridBagConstraints();
274: gridBagConstraints.gridx = 2;
275: gridBagConstraints.gridy = 0;
276: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHEAST;
277: gridBagConstraints.insets = new java.awt.Insets(0, 4, 0, 0);
278: jPanel2.add(jLabel3, gridBagConstraints);
279:
280: jSpinnerLeft.setMinimumSize(new java.awt.Dimension(50, 20));
281: jSpinnerLeft.setPreferredSize(new java.awt.Dimension(50, 20));
282: jSpinnerLeft
283: .addPropertyChangeListener(new java.beans.PropertyChangeListener() {
284: public void propertyChange(
285: java.beans.PropertyChangeEvent evt) {
286: jSpinnerLeftPropertyChange(evt);
287: }
288: });
289: gridBagConstraints = new java.awt.GridBagConstraints();
290: gridBagConstraints.gridx = 3;
291: gridBagConstraints.gridy = 0;
292: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
293: gridBagConstraints.insets = new java.awt.Insets(0, 4, 4, 4);
294: jPanel2.add(jSpinnerLeft, gridBagConstraints);
295:
296: jLabel4.setText("Top");
297: gridBagConstraints = new java.awt.GridBagConstraints();
298: gridBagConstraints.gridx = 2;
299: gridBagConstraints.gridy = 1;
300: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHEAST;
301: gridBagConstraints.insets = new java.awt.Insets(0, 4, 0, 0);
302: jPanel2.add(jLabel4, gridBagConstraints);
303:
304: jSpinnerTop.setMinimumSize(new java.awt.Dimension(50, 20));
305: jSpinnerTop.setPreferredSize(new java.awt.Dimension(50, 20));
306: gridBagConstraints = new java.awt.GridBagConstraints();
307: gridBagConstraints.gridx = 3;
308: gridBagConstraints.gridy = 1;
309: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
310: gridBagConstraints.insets = new java.awt.Insets(0, 4, 4, 4);
311: jPanel2.add(jSpinnerTop, gridBagConstraints);
312:
313: jLabel5.setText("Right");
314: gridBagConstraints = new java.awt.GridBagConstraints();
315: gridBagConstraints.gridx = 4;
316: gridBagConstraints.gridy = 0;
317: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHEAST;
318: gridBagConstraints.insets = new java.awt.Insets(0, 4, 0, 0);
319: jPanel2.add(jLabel5, gridBagConstraints);
320:
321: jSpinnerRight.setMinimumSize(new java.awt.Dimension(50, 20));
322: jSpinnerRight.setPreferredSize(new java.awt.Dimension(50, 20));
323: gridBagConstraints = new java.awt.GridBagConstraints();
324: gridBagConstraints.gridx = 5;
325: gridBagConstraints.gridy = 0;
326: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
327: gridBagConstraints.insets = new java.awt.Insets(0, 4, 4, 4);
328: jPanel2.add(jSpinnerRight, gridBagConstraints);
329:
330: jLabel6.setText("Bottom");
331: gridBagConstraints = new java.awt.GridBagConstraints();
332: gridBagConstraints.gridx = 4;
333: gridBagConstraints.gridy = 1;
334: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHEAST;
335: gridBagConstraints.insets = new java.awt.Insets(0, 4, 0, 0);
336: jPanel2.add(jLabel6, gridBagConstraints);
337:
338: jSpinnerBottom.setMinimumSize(new java.awt.Dimension(50, 20));
339: jSpinnerBottom.setPreferredSize(new java.awt.Dimension(50, 20));
340: gridBagConstraints = new java.awt.GridBagConstraints();
341: gridBagConstraints.gridx = 5;
342: gridBagConstraints.gridy = 1;
343: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
344: gridBagConstraints.insets = new java.awt.Insets(0, 4, 4, 4);
345: jPanel2.add(jSpinnerBottom, gridBagConstraints);
346:
347: gridBagConstraints = new java.awt.GridBagConstraints();
348: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
349: gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);
350: add(jPanel2, gridBagConstraints);
351:
352: jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(
353: javax.swing.BorderFactory.createEtchedBorder(),
354: "Border"));
355: jPanel1.setMinimumSize(new java.awt.Dimension(360, 230));
356: jPanel1.setPreferredSize(new java.awt.Dimension(360, 230));
357: jPanel1.setLayout(new java.awt.GridBagLayout());
358:
359: jPanel3.setBackground(new java.awt.Color(204, 204, 255));
360: jPanel3
361: .setBorder(javax.swing.BorderFactory
362: .createEtchedBorder(javax.swing.border.EtchedBorder.RAISED));
363: jPanel3.setMinimumSize(new java.awt.Dimension(100, 100));
364: jPanel3.setPreferredSize(new java.awt.Dimension(100, 100));
365: jPanel3.setLayout(new java.awt.GridBagLayout());
366: gridBagConstraints = new java.awt.GridBagConstraints();
367: gridBagConstraints.gridx = 2;
368: gridBagConstraints.gridy = 2;
369: jPanel1.add(jPanel3, gridBagConstraints);
370:
371: jComboBoxTop.setMinimumSize(new java.awt.Dimension(100, 24));
372: jComboBoxTop.setPreferredSize(new java.awt.Dimension(100, 24));
373: jComboBoxTop
374: .addActionListener(new java.awt.event.ActionListener() {
375: public void actionPerformed(
376: java.awt.event.ActionEvent evt) {
377: jComboBoxTopActionPerformed(evt);
378: }
379: });
380: gridBagConstraints = new java.awt.GridBagConstraints();
381: gridBagConstraints.gridx = 2;
382: gridBagConstraints.gridy = 0;
383: gridBagConstraints.insets = new java.awt.Insets(0, 0, 4, 0);
384: jPanel1.add(jComboBoxTop, gridBagConstraints);
385:
386: jButtonBoxColorTop.setBackground(new java.awt.Color(0, 0, 0));
387: jButtonBoxColorTop.setBorder(javax.swing.BorderFactory
388: .createEtchedBorder());
389: jButtonBoxColorTop.setMaximumSize(new java.awt.Dimension(100,
390: 10));
391: jButtonBoxColorTop.setMinimumSize(new java.awt.Dimension(100,
392: 10));
393: jButtonBoxColorTop.setPreferredSize(new java.awt.Dimension(100,
394: 10));
395: jButtonBoxColorTop
396: .addActionListener(new java.awt.event.ActionListener() {
397: public void actionPerformed(
398: java.awt.event.ActionEvent evt) {
399: jButtonBoxColorTopActionPerformed(evt);
400: }
401: });
402: gridBagConstraints = new java.awt.GridBagConstraints();
403: gridBagConstraints.gridx = 2;
404: gridBagConstraints.gridy = 1;
405: gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);
406: jPanel1.add(jButtonBoxColorTop, gridBagConstraints);
407:
408: jButtonBoxColorLeft.setBackground(new java.awt.Color(0, 0, 0));
409: jButtonBoxColorLeft.setBorder(javax.swing.BorderFactory
410: .createEtchedBorder());
411: jButtonBoxColorLeft.setMaximumSize(new java.awt.Dimension(10,
412: 100));
413: jButtonBoxColorLeft.setMinimumSize(new java.awt.Dimension(10,
414: 100));
415: jButtonBoxColorLeft.setPreferredSize(new java.awt.Dimension(10,
416: 100));
417: jButtonBoxColorLeft
418: .addActionListener(new java.awt.event.ActionListener() {
419: public void actionPerformed(
420: java.awt.event.ActionEvent evt) {
421: jButtonBoxColorLeftActionPerformed(evt);
422: }
423: });
424: gridBagConstraints = new java.awt.GridBagConstraints();
425: gridBagConstraints.gridx = 1;
426: gridBagConstraints.gridy = 2;
427: gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);
428: jPanel1.add(jButtonBoxColorLeft, gridBagConstraints);
429:
430: jComboBoxLeft.setMinimumSize(new java.awt.Dimension(100, 24));
431: jComboBoxLeft.setPreferredSize(new java.awt.Dimension(100, 24));
432: jComboBoxLeft
433: .addActionListener(new java.awt.event.ActionListener() {
434: public void actionPerformed(
435: java.awt.event.ActionEvent evt) {
436: jComboBoxLeftActionPerformed(evt);
437: }
438: });
439: gridBagConstraints = new java.awt.GridBagConstraints();
440: gridBagConstraints.gridx = 0;
441: gridBagConstraints.gridy = 2;
442: gridBagConstraints.insets = new java.awt.Insets(0, 0, 8, 0);
443: jPanel1.add(jComboBoxLeft, gridBagConstraints);
444:
445: jButtonBoxColorBottom
446: .setBackground(new java.awt.Color(0, 0, 0));
447: jButtonBoxColorBottom.setBorder(javax.swing.BorderFactory
448: .createEtchedBorder());
449: jButtonBoxColorBottom.setMaximumSize(new java.awt.Dimension(
450: 100, 10));
451: jButtonBoxColorBottom.setMinimumSize(new java.awt.Dimension(
452: 100, 10));
453: jButtonBoxColorBottom.setPreferredSize(new java.awt.Dimension(
454: 100, 10));
455: jButtonBoxColorBottom
456: .addActionListener(new java.awt.event.ActionListener() {
457: public void actionPerformed(
458: java.awt.event.ActionEvent evt) {
459: jButtonBoxColorBottomActionPerformed(evt);
460: }
461: });
462: gridBagConstraints = new java.awt.GridBagConstraints();
463: gridBagConstraints.gridx = 2;
464: gridBagConstraints.gridy = 3;
465: gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);
466: jPanel1.add(jButtonBoxColorBottom, gridBagConstraints);
467:
468: jButtonBoxColorRight.setBackground(new java.awt.Color(0, 0, 0));
469: jButtonBoxColorRight.setBorder(javax.swing.BorderFactory
470: .createEtchedBorder());
471: jButtonBoxColorRight.setMaximumSize(new java.awt.Dimension(10,
472: 100));
473: jButtonBoxColorRight.setMinimumSize(new java.awt.Dimension(10,
474: 100));
475: jButtonBoxColorRight.setPreferredSize(new java.awt.Dimension(
476: 10, 100));
477: jButtonBoxColorRight
478: .addActionListener(new java.awt.event.ActionListener() {
479: public void actionPerformed(
480: java.awt.event.ActionEvent evt) {
481: jButtonBoxColorRightActionPerformed(evt);
482: }
483: });
484: gridBagConstraints = new java.awt.GridBagConstraints();
485: gridBagConstraints.gridx = 3;
486: gridBagConstraints.gridy = 2;
487: gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);
488: jPanel1.add(jButtonBoxColorRight, gridBagConstraints);
489:
490: jComboBoxRight.setMinimumSize(new java.awt.Dimension(100, 24));
491: jComboBoxRight
492: .setPreferredSize(new java.awt.Dimension(100, 24));
493: jComboBoxRight
494: .addActionListener(new java.awt.event.ActionListener() {
495: public void actionPerformed(
496: java.awt.event.ActionEvent evt) {
497: jComboBoxRightActionPerformed(evt);
498: }
499: });
500: gridBagConstraints = new java.awt.GridBagConstraints();
501: gridBagConstraints.gridx = 4;
502: gridBagConstraints.gridy = 2;
503: gridBagConstraints.insets = new java.awt.Insets(0, 0, 8, 0);
504: jPanel1.add(jComboBoxRight, gridBagConstraints);
505:
506: jComboBoxBottom.setMinimumSize(new java.awt.Dimension(100, 24));
507: jComboBoxBottom
508: .setPreferredSize(new java.awt.Dimension(100, 24));
509: jComboBoxBottom
510: .addActionListener(new java.awt.event.ActionListener() {
511: public void actionPerformed(
512: java.awt.event.ActionEvent evt) {
513: jComboBoxBottomActionPerformed(evt);
514: }
515: });
516: gridBagConstraints = new java.awt.GridBagConstraints();
517: gridBagConstraints.gridx = 2;
518: gridBagConstraints.gridy = 4;
519: gridBagConstraints.insets = new java.awt.Insets(4, 0, 4, 0);
520: jPanel1.add(jComboBoxBottom, gridBagConstraints);
521:
522: gridBagConstraints = new java.awt.GridBagConstraints();
523: gridBagConstraints.gridx = 0;
524: gridBagConstraints.gridy = 1;
525: gridBagConstraints.gridheight = 3;
526: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
527: gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
528: gridBagConstraints.weightx = 1.0;
529: gridBagConstraints.weighty = 1.0;
530: gridBagConstraints.insets = new java.awt.Insets(2, 6, 6, 6);
531: add(jPanel1, gridBagConstraints);
532:
533: jPanelBorderEditorContainer.setBorder(javax.swing.BorderFactory
534: .createTitledBorder("Borders"));
535: jPanelBorderEditorContainer
536: .setLayout(new java.awt.BorderLayout());
537: gridBagConstraints = new java.awt.GridBagConstraints();
538: gridBagConstraints.gridx = 0;
539: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
540: gridBagConstraints.weightx = 1.0;
541: gridBagConstraints.weighty = 1.0;
542: gridBagConstraints.insets = new java.awt.Insets(2, 6, 6, 6);
543: add(jPanelBorderEditorContainer, gridBagConstraints);
544: }// </editor-fold>//GEN-END:initComponents
545:
546: private void jSpinnerLeftPropertyChange(
547: java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_jSpinnerLeftPropertyChange
548:
549: }//GEN-LAST:event_jSpinnerLeftPropertyChange
550:
551: private void jComboBoxLeftActionPerformed(
552: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBoxLeftActionPerformed
553: if (init)
554: return;
555: box.setLeftBorder(Misc.getComboboxSelectedValue(jComboBoxLeft)
556: + "");
557: fireActionListenerActionPerformed(new java.awt.event.ActionEvent(
558: this , 0, "LeftBorder"));
559: }//GEN-LAST:event_jComboBoxLeftActionPerformed
560:
561: private void jComboBoxBottomActionPerformed(
562: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBoxBottomActionPerformed
563: if (init)
564: return;
565: box.setBottomBorder(Misc
566: .getComboboxSelectedValue(jComboBoxBottom)
567: + "");
568: fireActionListenerActionPerformed(new java.awt.event.ActionEvent(
569: this , 0, "BottomBorder"));
570: }//GEN-LAST:event_jComboBoxBottomActionPerformed
571:
572: private void jComboBoxRightActionPerformed(
573: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBoxRightActionPerformed
574: if (init)
575: return;
576: box.setRightBorder(Misc
577: .getComboboxSelectedValue(jComboBoxRight)
578: + "");
579: fireActionListenerActionPerformed(new java.awt.event.ActionEvent(
580: this , 0, "RightBorder"));
581: }//GEN-LAST:event_jComboBoxRightActionPerformed
582:
583: private void jComboBoxTopActionPerformed(
584: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBoxTopActionPerformed
585: if (init)
586: return;
587: box.setTopBorder(Misc.getComboboxSelectedValue(jComboBoxTop)
588: + "");
589: fireActionListenerActionPerformed(new java.awt.event.ActionEvent(
590: this , 0, "TopBorder"));
591: }//GEN-LAST:event_jComboBoxTopActionPerformed
592:
593: private void jButtonBoxColorLeftActionPerformed(
594: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonBoxColorLeftActionPerformed
595: java.awt.Color color = HexColorChooserPanel.showDialog(null,
596: I18n.getString("messages.boxPanel.selectColor",
597: "Select color..."),
598: //"Select color...",
599: this .jButtonBoxColorLeft.getBackground());
600: if (color != null) {
601: box.setLeftBorderColor(color);
602: this .jButtonBoxColorLeft.setBackground(color);
603: fireActionListenerActionPerformed(new java.awt.event.ActionEvent(
604: this , 0, "LeftBorderColor"));
605: }
606: }//GEN-LAST:event_jButtonBoxColorLeftActionPerformed
607:
608: private void jButtonBoxColorBottomActionPerformed(
609: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonBoxColorBottomActionPerformed
610: java.awt.Color color = HexColorChooserPanel.showDialog(null,
611: I18n.getString("messages.boxPanel.selectColor",
612: "Select color..."),
613: //"Select color...",
614: this .jButtonBoxColorBottom.getBackground());
615: if (color != null) {
616: box.setBottomBorderColor(color);
617: this .jButtonBoxColorBottom.setBackground(color);
618: fireActionListenerActionPerformed(new java.awt.event.ActionEvent(
619: this , 0, "BottomBorderColor"));
620: }
621: }//GEN-LAST:event_jButtonBoxColorBottomActionPerformed
622:
623: private void jButtonBoxColorRightActionPerformed(
624: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonBoxColorRightActionPerformed
625: java.awt.Color color = HexColorChooserPanel.showDialog(null,
626: I18n.getString("messages.boxPanel.selectColor",
627: "Select color..."),
628: //"Select color...",
629: this .jButtonBoxColorRight.getBackground());
630: if (color != null) {
631: box.setRightBorderColor(color);
632: this .jButtonBoxColorRight.setBackground(color);
633: fireActionListenerActionPerformed(new java.awt.event.ActionEvent(
634: this , 0, "RightBorderColor"));
635: }
636: }//GEN-LAST:event_jButtonBoxColorRightActionPerformed
637:
638: private void jButtonBoxColorTopActionPerformed(
639: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonBoxColorTopActionPerformed
640: java.awt.Color color = HexColorChooserPanel.showDialog(null,
641: I18n.getString("messages.boxPanel.selectColor",
642: "Select color..."),
643: //"Select color...",
644: this .jButtonBoxColorTop.getBackground());
645: if (color != null) {
646: box.setTopBorderColor(color);
647: this .jButtonBoxColorTop.setBackground(color);
648: fireActionListenerActionPerformed(new java.awt.event.ActionEvent(
649: this , 0, "TopBorderColor"));
650: }
651: }//GEN-LAST:event_jButtonBoxColorTopActionPerformed
652:
653: /**
654: * Registers ActionListener to receive events.
655: * @param listener The listener to register.
656: */
657: public synchronized void addActionListener(
658: java.awt.event.ActionListener listener) {
659:
660: if (listenerList == null) {
661: listenerList = new javax.swing.event.EventListenerList();
662: }
663: listenerList.add(java.awt.event.ActionListener.class, listener);
664: }
665:
666: /**
667: * Removes ActionListener from the list of listeners.
668: * @param listener The listener to remove.
669: */
670: public synchronized void removeActionListener(
671: java.awt.event.ActionListener listener) {
672:
673: listenerList.remove(java.awt.event.ActionListener.class,
674: listener);
675: }
676:
677: /**
678: * Notifies all registered listeners about the event.
679: *
680: * @param event The event to be fired
681: */
682: private void fireActionListenerActionPerformed(
683: java.awt.event.ActionEvent event) {
684:
685: if (listenerList == null)
686: return;
687: Object[] listeners = listenerList.getListenerList();
688: for (int i = listeners.length - 2; i >= 0; i -= 2) {
689: if (listeners[i] == java.awt.event.ActionListener.class) {
690: ((java.awt.event.ActionListener) listeners[i + 1])
691: .actionPerformed(event);
692: }
693: }
694:
695: if (samplePanel != null)
696: samplePanel.setBox(box);
697: }
698:
699: public Box getBox() {
700: return box;
701: }
702:
703: public void setBox(Box box) {
704: if (box == null)
705: box = new Box();
706:
707: this .box = box;
708: init = true;
709:
710: java.awt.Color c = box.getLeftBorderColor();
711: this .jButtonBoxColorLeft.setBackground(c);
712: this .jButtonBoxColorLeft.updateUI();
713:
714: c = box.getTopBorderColor();
715: this .jButtonBoxColorTop.setBackground(c);
716: this .jButtonBoxColorTop.updateUI();
717:
718: c = box.getRightBorderColor();
719: this .jButtonBoxColorRight.setBackground(c);
720: this .jButtonBoxColorRight.updateUI();
721:
722: c = box.getBottomBorderColor();
723: this .jButtonBoxColorBottom.setBackground(c);
724: this .jButtonBoxColorBottom.updateUI();
725:
726: Misc.setComboboxSelectedTagValue(jComboBoxTop, box
727: .getTopBorder());
728: Misc.setComboboxSelectedTagValue(jComboBoxLeft, box
729: .getLeftBorder());
730: Misc.setComboboxSelectedTagValue(jComboBoxRight, box
731: .getRightBorder());
732: Misc.setComboboxSelectedTagValue(jComboBoxBottom, box
733: .getBottomBorder());
734:
735: jSpinnerBottom.setValue(new Integer(box.getBottomPadding()));
736: jSpinnerTop.setValue(new Integer(box.getTopPadding()));
737: jSpinnerLeft.setValue(new Integer(box.getLeftPadding()));
738: jSpinnerRight.setValue(new Integer(box.getRightPadding()));
739:
740: if (samplePanel != null)
741: samplePanel.setBox(box);
742:
743: borderEditorPanel.setBox(box);
744:
745: init = false;
746:
747: }
748:
749: // Variables declaration - do not modify//GEN-BEGIN:variables
750: private javax.swing.JButton jButtonBoxColorBottom;
751: private javax.swing.JButton jButtonBoxColorLeft;
752: private javax.swing.JButton jButtonBoxColorRight;
753: private javax.swing.JButton jButtonBoxColorTop;
754: private javax.swing.JComboBox jComboBoxBottom;
755: private javax.swing.JComboBox jComboBoxLeft;
756: private javax.swing.JComboBox jComboBoxRight;
757: private javax.swing.JComboBox jComboBoxTop;
758: private javax.swing.JLabel jLabel3;
759: private javax.swing.JLabel jLabel4;
760: private javax.swing.JLabel jLabel5;
761: private javax.swing.JLabel jLabel6;
762: private javax.swing.JPanel jPanel1;
763: private javax.swing.JPanel jPanel2;
764: private javax.swing.JPanel jPanel3;
765: private javax.swing.JPanel jPanelBorderEditorContainer;
766: private javax.swing.JSpinner jSpinnerBottom;
767: private javax.swing.JSpinner jSpinnerLeft;
768: private javax.swing.JSpinner jSpinnerRight;
769: private javax.swing.JSpinner jSpinnerTop;
770:
771: // End of variables declaration//GEN-END:variables
772:
773: public void applyI18n() {
774: // Start autogenerated code ----------------------
775: jLabel3.setText(I18n.getString("boxPanel.label3", "Left"));
776: jLabel4.setText(I18n.getString("boxPanel.label4", "Top"));
777: jLabel5.setText(I18n.getString("boxPanel.label5", "Right"));
778: jLabel6.setText(I18n.getString("boxPanel.label6", "Bottom"));
779: // End autogenerated code ----------------------
780:
781: ((javax.swing.border.TitledBorder) jPanel1.getBorder())
782: .setTitle(it.businesslogic.ireport.util.I18n.getString(
783: "boxPanel.panelBorder.Border", "Border"));
784: ((javax.swing.border.TitledBorder) jPanel2.getBorder())
785: .setTitle(it.businesslogic.ireport.util.I18n.getString(
786: "boxPanel.panelBorder.Padding", "Padding"));
787: }
788:
789: public void actionPerformed(ActionEvent e) {
790: fireActionListenerActionPerformed(e);
791: }
792: }
|