bandsdialog.java

来自「优秀的打印控件全源代码,类似水晶表的设计器!」· Java 代码 · 共 430 行 · 第 1/2 页

JAVA
430
字号
/* * BandsDialog.java * *  iReport  --  Visual designer for generating JasperReports Documents *  Copyright (C) 2002-2003  Giulio Toffoli gt@businesslogic.it * *  This program is free software; you can redistribute  and/or modify *  it under the terms of the GNU General Public License as published by *  the Free Software Foundation; either version 2 of the License, or *  (at your option) any later version. * *  This program is distributed in the hope that it will be useful, *  but WITHOUT ANY WARRANTY; without even the implied warranty of *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the *  GNU General Public License for more details. * *  You should have received a copy of the GNU General Public License *  along with this program; if not, write to the Free Software *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * *  Giulio Toffoli *  Via T.Aspetti, 233 *  35100 Padova ITALY *  gt@businesslogic.it * * * Created on 10 maggio 2003, 9.51 */package it.businesslogic.ireport.gui;import javax.swing.table.*;import javax.swing.*;import javax.swing.event.*;import it.businesslogic.ireport.*;import it.businesslogic.ireport.util.*;import java.util.*;/** * * @author  Administrator */public class BandsDialog extends javax.swing.JDialog {            private JReportFrame jReportFrame=null;        /** Creates new form BandsDialog */    public BandsDialog(java.awt.Frame parent, boolean modal) {        super(parent, modal);        initComponents();         this.setSize(520, 250);         Misc.centerFrame(this);         jListBands.setModel(new DefaultListModel());                                 this.jRTextExpressionArea.getDocument().addDocumentListener( new javax.swing.event.DocumentListener() {            public void changedUpdate(javax.swing.event.DocumentEvent evt)            {                jRTextExpressionAreaTextChanged();            }            public void insertUpdate(javax.swing.event.DocumentEvent evt) {                jRTextExpressionAreaTextChanged();            }            public void removeUpdate(javax.swing.event.DocumentEvent evt) {                jRTextExpressionAreaTextChanged();            }        });                       }            private void jRTextExpressionAreaTextChanged()    {        if (jListBands.getSelectedValue()!= null &&            jListBands.getSelectedValue() instanceof Band)        {            Band selectedBand = (Band)jListBands.getSelectedValue();            selectedBand.setPrintWhenExpression( jRTextExpressionArea.getText() );        }    }        public void jTableBandsListSelectionValueChanged(javax.swing.event.ListSelectionEvent e)    {           }         public void updateBands() {             Object selected = jListBands.getSelectedValue();         boolean isSelected = false;        ((DefaultListModel)jListBands.getModel()).removeAllElements();            if (jReportFrame == null) return;        Enumeration e = jReportFrame.getReport().getBands().elements();        while (e.hasMoreElements())        {            it.businesslogic.ireport.Band band = (it.businesslogic.ireport.Band)e.nextElement();            ((DefaultListModel)jListBands.getModel()).addElement(band);                if (selected == band)            {                jListBands.setSelectedValue(selected, true);                isSelected = true;            }        }                    if (!isSelected && jReportFrame.getReport().getBands().size() > 0)        {            jListBands.setSelectedIndex(0);        }    }    /** This method is called from within the constructor to     * initialize the form.     * WARNING: Do NOT modify this code. The content of this method is     * always regenerated by the Form Editor.     */        private void initComponents() {//GEN-BEGIN:initComponents                java.awt.GridBagConstraints gridBagConstraints;                jPanelFields = new javax.swing.JPanel();                jPanelButtons = new javax.swing.JPanel();                jPanel2 = new javax.swing.JPanel();                jPanel3 = new javax.swing.JPanel();                jLabel1 = new javax.swing.JLabel();                jLabel2 = new javax.swing.JLabel();                jNumberFieldHeight = new it.businesslogic.ireport.gui.JNumberField();                jCheckBoxSplitAllowed = new javax.swing.JCheckBox();                jRTextExpressionArea = new it.businesslogic.ireport.gui.JRTextExpressionArea();                jScrollPane1 = new javax.swing.JScrollPane();                jListBands = new javax.swing.JList();                addWindowListener(new java.awt.event.WindowAdapter() {                        public void windowClosing(java.awt.event.WindowEvent evt) {                                closeDialog(evt);                        }                });                jPanelFields.setLayout(new java.awt.BorderLayout(4, 4));                jPanelButtons.setLayout(new java.awt.BorderLayout());                jPanelButtons.setBorder(new javax.swing.border.TitledBorder(new javax.swing.border.EtchedBorder(), "Band properties", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Dialog", 0, 11)));                jPanelButtons.setMinimumSize(new java.awt.Dimension(100, 10));                jPanelButtons.setPreferredSize(new java.awt.Dimension(100, 10));                jPanel2.setLayout(new java.awt.BorderLayout());                jPanel3.setLayout(new java.awt.GridBagLayout());                jPanel3.setPreferredSize(new java.awt.Dimension(10, 55));                jLabel1.setFont(new java.awt.Font("Dialog", 0, 11));                jLabel1.setText("Print When Expression");                gridBagConstraints = new java.awt.GridBagConstraints();                gridBagConstraints.gridx = 0;                gridBagConstraints.gridy = 2;                gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3);                gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;                jPanel3.add(jLabel1, gridBagConstraints);                jLabel2.setFont(new java.awt.Font("Dialog", 0, 11));                jLabel2.setText("Band height");                gridBagConstraints = new java.awt.GridBagConstraints();                gridBagConstraints.gridx = 0;                gridBagConstraints.gridy = 0;                gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3);                gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;                jPanel3.add(jLabel2, gridBagConstraints);                jNumberFieldHeight.setHorizontalAlignment(javax.swing.JTextField.RIGHT);                jNumberFieldHeight.setText("0");                try {                        jNumberFieldHeight.setDecimals(0);                } catch (java.beans.PropertyVetoException e1) {                        e1.printStackTrace();                }                jNumberFieldHeight.addActionListener(new java.awt.event.ActionListener() {                        public void actionPerformed(java.awt.event.ActionEvent evt) {                                jNumberFieldHeightActionPerformed(evt);                        }                });                gridBagConstraints = new java.awt.GridBagConstraints();                gridBagConstraints.gridx = 0;                gridBagConstraints.gridy = 1;                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;                gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3);                gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;                jPanel3.add(jNumberFieldHeight, gridBagConstraints);                jCheckBoxSplitAllowed.setFont(new java.awt.Font("Dialog", 0, 11));                jCheckBoxSplitAllowed.setText("Split allowed");                jCheckBoxSplitAllowed.setSelected(true);                jCheckBoxSplitAllowed.addActionListener(new java.awt.event.ActionListener() {                        public void actionPerformed(java.awt.event.ActionEvent evt) {                                jCheckBoxSplitAllowedActionPerformed(evt);                        }                });                gridBagConstraints = new java.awt.GridBagConstraints();                gridBagConstraints.gridx = 1;                gridBagConstraints.gridy = 0;                gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3);                gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;                jPanel3.add(jCheckBoxSplitAllowed, gridBagConstraints);                jRTextExpressionArea.setBorder(new javax.swing.border.EtchedBorder());                jRTextExpressionArea.setMinimumSize(new java.awt.Dimension(0, 0));                jRTextExpressionArea.setElectricScroll(0);                gridBagConstraints = new java.awt.GridBagConstraints();                gridBagConstraints.gridx = 0;                gridBagConstraints.gridy = 3;                gridBagConstraints.gridwidth = 2;                gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;                gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3);

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?