⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 reportpropertiesframe.java

📁 优秀的打印控件全源代码,类似水晶表的设计器!
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
        pack();        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();        java.awt.Dimension dialogSize = getSize();        setLocation((screenSize.width-dialogSize.width)/2,(screenSize.height-dialogSize.height)/2);    }//GEN-END:initComponents        private void jComboBoxScriptletHandlingActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBoxScriptletHandlingActionPerformed        if (jComboBoxScriptletHandling.getSelectedIndex() == 0) {            jTextFieldScriptletClass.setText("");            jTextFieldScriptletClass.setEnabled( false );        }        else if (jComboBoxScriptletHandling.getSelectedIndex() == 1) {            jTextFieldScriptletClass.setText("");            jTextFieldScriptletClass.setEnabled( false );        }        else if (jComboBoxScriptletHandling.getSelectedIndex() == 2) {            jTextFieldScriptletClass.setEnabled( true );        }        this.scriptletHandling = jComboBoxScriptletHandling.getSelectedIndex();            }//GEN-LAST:event_jComboBoxScriptletHandlingActionPerformed        private void jCheckBoxSummaryOnNewPageActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBoxSummaryOnNewPageActionPerformed        this.summaryOnNewPage = jCheckBoxSummaryOnNewPage.isSelected();    }//GEN-LAST:event_jCheckBoxSummaryOnNewPageActionPerformed        private void jComboBoxOrientationActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBoxOrientationActionPerformed        orientation = (String)this.jComboBoxOrientation.getSelectedItem();        int reportSwitch = 0;        adjustSizes();    }//GEN-LAST:event_jComboBoxOrientationActionPerformed        private void jComboBoxSizeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBoxSizeActionPerformed        reportFormat = (String)this.jComboBoxSize.getSelectedItem();        if( reportFormat!=null && !reportFormat.equalsIgnoreCase( "CUSTOM") ) {            // set the Size fields.            Point p = PageSize.getFormatSize(reportFormat);                        setReportWidth(p.x);            setReportHeight(p.y);                        // reshuffle Height and Width according to Orientation            adjustSizes();        }    }//GEN-LAST:event_jComboBoxSizeActionPerformed        private void jComboBoxXMLEncodingActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBoxXMLEncodingActionPerformed        this.xmlEncoding = jComboBoxXMLEncoding.getSelectedItem()+"";    }//GEN-LAST:event_jComboBoxXMLEncodingActionPerformed        private void jComboBoxWhenNoDataActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBoxWhenNoDataActionPerformed        this.whenNoDataType = jComboBoxWhenNoData.getSelectedItem()+"";    }//GEN-LAST:event_jComboBoxWhenNoDataActionPerformed        private void jComboBoxPrintOrderActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBoxPrintOrderActionPerformed        this.printOrder = jComboBoxPrintOrder.getSelectedItem()+"";    }//GEN-LAST:event_jComboBoxPrintOrderActionPerformed        private void jNumberFieldColumnsSpacingActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jNumberFieldColumnsSpacingActionPerformed                double convert = 1.0;        convert = this.getConversionUnit(this.jComboBoxColumnsSpacingUnit);        //int old_spacing = getColumnsSpacing();        this.columnsSpacing  = (int)Unit.convertToPixels(jNumberFieldColumnsSpacing.getValue(),convert);                int avail = getReportWidth() - getLeftMargin() - getRightMargin();        int dim = avail;                // calculate space...        if ((this.columnsSpacing*(getColumns()-1)) > avail) {            MessageBox.show("WARNING: Column spacing too big!", "Error", MessageBox.OK | MessageBox.ICONWARNING );        }        while (dim>0 && (dim*getColumns())+(getColumnsSpacing()*(getColumns()-1)) > avail) {            dim--;        }                this.setColumnsWidth(dim);    }//GEN-LAST:event_jNumberFieldColumnsSpacingActionPerformed        private void jNumberFieldColumnsWidthActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jNumberFieldColumnsWidthActionPerformed        this.columnsWidth = (int)Unit.convertToPixels(this.jNumberFieldColumnsWidth.getValue(),this.getConversionUnit(jComboBoxColumnsWidthUnit));    }//GEN-LAST:event_jNumberFieldColumnsWidthActionPerformed        private void jComboBoxColumnsWidthUnitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBoxColumnsWidthUnitActionPerformed        this.adjustValue(jComboBoxColumnsWidthUnit,jNumberFieldColumnsWidth, this.getColumnsWidth() );    }//GEN-LAST:event_jComboBoxColumnsWidthUnitActionPerformed        private void jNumberFieldColumnsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jNumberFieldColumnsActionPerformed                this.columns = (int)jNumberFieldColumns.getValue();        // calculate space...        int avail = getReportWidth() - getLeftMargin() - getRightMargin() - (this.getColumns()-1)*getColumnsSpacing();        int dim = avail;        dim = (int)( (double)dim/(double)this.getColumns());                while ( (dim*this.getColumns()) > avail) {            dim--;        }        this.setColumnsWidth(dim);    }//GEN-LAST:event_jNumberFieldColumnsActionPerformed        private void jComboBoxColumnsSpacingUnitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBoxColumnsSpacingUnitActionPerformed        this.adjustValue(jComboBoxColumnsSpacingUnit,jNumberFieldColumnsSpacing, this.getColumnsSpacing() );    }//GEN-LAST:event_jComboBoxColumnsSpacingUnitActionPerformed        private void jTextFieldNameActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextFieldNameActionPerformed        this.reportName = jTextFieldName.getText().trim();            }//GEN-LAST:event_jTextFieldNameActionPerformed        private void jTextFieldScriptletClassActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextFieldScriptletClassActionPerformed        this.scriptletClass = jTextFieldScriptletClass.getText().trim();    }//GEN-LAST:event_jTextFieldScriptletClassActionPerformed        private void jComboBoxTopMarginUnitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBoxTopMarginUnitActionPerformed        this.adjustValue(jComboBoxTopMarginUnit,jNumberFieldTopMargin, this.getTopMargin());    }//GEN-LAST:event_jComboBoxTopMarginUnitActionPerformed        private void jComboBoxBottomMarginUnitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBoxBottomMarginUnitActionPerformed        this.adjustValue(jComboBoxBottomMarginUnit,jNumberFieldBottomMargin, this.getBottomMargin());    }//GEN-LAST:event_jComboBoxBottomMarginUnitActionPerformed        private void jComboBoxLeftMarginUnitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBoxLeftMarginUnitActionPerformed        this.adjustValue(jComboBoxLeftMarginUnit,jNumberFieldLeftMargin, this.getLeftMargin());    }//GEN-LAST:event_jComboBoxLeftMarginUnitActionPerformed        private void jComboBoxRightMarginUnitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBoxRightMarginUnitActionPerformed        this.adjustValue(jComboBoxRightMarginUnit,jNumberFieldRightMargin, this.getRightMargin());    }//GEN-LAST:event_jComboBoxRightMarginUnitActionPerformed        private void jNumberFieldRightMarginActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jNumberFieldRightMarginActionPerformed        rightMargin = (int)Unit.convertToPixels(this.jNumberFieldRightMargin.getValue(),this.getConversionUnit(jComboBoxRightMarginUnit));    }//GEN-LAST:event_jNumberFieldRightMarginActionPerformed        private void jNumberFieldLeftMarginActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jNumberFieldLeftMarginActionPerformed        leftMargin = (int)Unit.convertToPixels(this.jNumberFieldLeftMargin.getValue(),this.getConversionUnit(jComboBoxLeftMarginUnit));            }//GEN-LAST:event_jNumberFieldLeftMarginActionPerformed        private void jNumberFieldBottomMarginActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jNumberFieldBottomMarginActionPerformed        bottomMargin = (int)Unit.convertToPixels(this.jNumberFieldBottomMargin.getValue(),this.getConversionUnit(jComboBoxBottomMarginUnit));    }//GEN-LAST:event_jNumberFieldBottomMarginActionPerformed        private void jNumberFieldTopMarginActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jNumberFieldTopMarginActionPerformed        topMargin = (int)Unit.convertToPixels(this.jNumberFieldTopMargin.getValue(),this.getConversionUnit(jComboBoxTopMarginUnit));    }//GEN-LAST:event_jNumberFieldTopMarginActionPerformed        private void jComboBoxHUnitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBoxHUnitActionPerformed        this.adjustValue(jComboBoxHUnit,jNumberFieldHeight, this.getReportHeight());    }//GEN-LAST:event_jComboBoxHUnitActionPerformed        private void jNumberFieldHeightActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jNumberFieldHeightActionPerformed        this.jComboBoxSize.setSelectedItem("Custom");        reportHeight = (int)Unit.convertToPixels(this.jNumberFieldHeight.getValue(),this.getConversionUnit(jComboBoxHUnit));        adjustOrientation();    }//GEN-LAST:event_jNumberFieldHeightActionPerformed        private void jNumberFieldWidthActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jNumberFieldWidthActionPerformed        this.jComboBoxSize.setSelectedItem("Custom");        reportWidth = (int)Unit.convertToPixels(this.jNumberFieldWidth.getValue(),this.getConversionUnit(jComboBoxWUnit));        adjustOrientation();    }//GEN-LAST:event_jNumberFieldWidthActionPerformed        private void jComboBoxWUnitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBoxWUnitActionPerformed        this.adjustValue(jComboBoxWUnit,jNumberFieldWidth, this.getReportWidth());            }//GEN-LAST:event_jComboBoxWUnitActionPerformed        private void jCheckBoxTitleOnNewPageActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBoxTitleOnNewPageActionPerformed        this.titleOnNewPage = jCheckBoxTitleOnNewPage.isSelected();    }//GEN-LAST:event_jCheckBoxTitleOnNewPageActionPerformed        private void jButtonOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonOKActionPerformed        this.reportName = jTextFieldName.getText();        this.scriptletClass = jTextFieldScriptletClass.getText();        //System.out.println("Il nome :"+this.getReportName());        this.setDialogResult( JOptionPane.OK_OPTION );        this.setVisible(false);        //this.dispose();    }//GEN-LAST:event_jButtonOKActionPerformed        private void formWindowOpened(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowOpened            }//GEN-LAST:event_formWindowOpened        private void jButtonCANCELActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonCANCELActionPerformed        this.setDialogResult( JOptionPane.CANCEL_OPTION );        this.dispose();    }//GEN-LAST:event_jButtonCANCELActionPerformed        /** Exit the Application */    private void exitForm(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_exitForm        this.setDialogResult(  JOptionPane.CLOSED_OPTION );        this.dispose();    }//GEN-LAST:event_exitForm        /**     * @param args the command line arguments     */    public static void main(String args[]) {        new ReportPropertiesFrame(null,true).show();    }        /** Getter for property dialogResult.     * @return Value of property dialogResult.     *     */    public int getDialogResult() {        return this.dialogResult;    }        /** Setter for property dialogResult.     * @param dialogResult New value of property dialogResult.     *     */    public void setDialogResult(int dialogResult) {        this.dialogResult = dialogResult;    }            /**     *  This method convert the old value in new value according with the Unit selected     */    public void adjustValue(javax.swing.JComboBox unitCombo, JNumberField numberField, int store_value) {        try {            if (unitCombo.getSelectedIndex() == 0) {                numberField.setDecimals(0);                numberField.setInteger(true);                numberField.setValue(store_value);            }            else if (unitCombo.getSelectedIndex() == 1) {                numberField.setDecimals(3);                numberField.setInteger(false);                numberField.setValue( Unit.convertPixelsToInches(store_value) );            }            else if (unitCombo.getSelectedIndex() == 2) {                numberField.setDecimals(3);                numberField.setInteger(false);                numberField.setValue( Unit.convertPixelsToCentimeters( store_value) );            }            else if (unitCombo.getSelectedIndex() == 3) {                numberField.setDecimals(3);                numberField.setInteger(false);                numberField.setValue( Unit.convertPixelsToMillimeters( store_value) );            }        } catch (Exception ex) {}    }            private double getConversionUnit(javax.swing.JComboBox comboBox) {        double convert = 1.0;        if (comboBox.getSelectedIndex() == 1) convert = Unit.INCHES;        else if (comboBox.getSelectedIndex() == 2) convert = Unit.CENTIMETERS;        else if (comboBox.getSelectedIndex() == 3) convert = Unit.MILLIMETERS;        return convert;    }        /** Getter for property reportHeight.     * @return Value of property reportHeight.     *     */    public int getReportHeight() {        return reportHeight;    }        /** Setter for property reportHeight.     * @param reportHeight New value of property reportHeight.     *     */    public void setReportHeight(int reportHeight) {        this.reportHeight = reportHeight;        jComboBoxHUnitActionPerformed(new java.awt.event.ActionEvent(jComboBoxHUnit,0,""));    }        /** Getter for property reportWidth.     * @return Value of property reportWidth.     *     */    public int getReportWidth() {        return reportWidth;    }        /** Setter for property reportWidth.     * @param reportWidth New value of property reportWidth.     *     */    public void setReportWidth(int reportWidth) {        this.reportWidth = reportWidth;        jComboBoxWUnitActionPerformed(new java.awt.event.ActionEvent(jComboBoxWUnit,0,""));    }        /** Getter for property rightMargin.     * @return Value of property rightMargin.     *     */    public int getRightMargin() {        return rightMargin;    }        /** Setter for property rightMargin.     * @param rightMargin New value of property rightMargin.     *

⌨️ 快捷键说明

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