jrfontdialog.java
来自「优秀的打印控件全源代码,类似水晶表的设计器!」· Java 代码 · 共 572 行 · 第 1/2 页
JAVA
572 行
// Set band to all.... if (jComboBoxPDFFontName.getSelectedItem() == null || (jComboBoxPDFFontName.getSelectedItem()+"").equals("")) return; // Set the new value for all selected elements... String fontName = ""+ jComboBoxPDFFontName.getSelectedItem(); if (fontName != null && fontName.equals("External TTF font...")) { this.jComboBoxTTFFont.setEnabled(true); this.jLabelTTF.setEnabled(true); } else { this.jComboBoxTTFFont.setEnabled(false); this.jLabelTTF.setEnabled(false); } }//GEN-LAST:event_jComboBoxPDFFontNameActionPerformed private void jButtonCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonCancelActionPerformed setVisible(false); this.setDialogResult( javax.swing.JOptionPane.CANCEL_OPTION); dispose(); }//GEN-LAST:event_jButtonCancelActionPerformed private void jButtonOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonOKActionPerformed if (this.jTextFieldReportFont.getText().trim().length() <= 0) { javax.swing.JOptionPane.showMessageDialog(this,"Please insert a valid report font name!","Invalid report font name!",javax.swing.JOptionPane.WARNING_MESSAGE ); return; } iReportFont = new IReportFont(); iReportFont.setReportFont( this.jTextFieldReportFont.getText() ); iReportFont.setBold( this.jCheckBoxBold.isSelected()); iReportFont.setDefaultFont(false); iReportFont.setFontName(""+ this.jComboBoxFontName.getSelectedItem()); iReportFont.setFontSize( (int)jNumberComboBoxSize.getValue()); iReportFont.setItalic( this.jCheckBoxItalic.isSelected()); iReportFont.setPDFFontName( this.jComboBoxFontName.getSelectedItem()+""); //if (Misc.nvl( this.jComboBoxFontName.getSelectedItem(),"").indexOf("TTF") != 0) //{ // iReportFont.setPDFFontName( this.jComboBoxTTFFont.getSelectedItem()+""); //} iReportFont.setPDFFontName(this.jComboBoxPDFFontName.getSelectedItem()+""); if (iReportFont.getPDFFontName().equals("External TTF font...")) { if (this.jComboBoxTTFFont.getSelectedItem() != null && this.jComboBoxTTFFont.getSelectedItem() instanceof IRFont) iReportFont.setPDFFontName( ((IRFont) this.jComboBoxTTFFont.getSelectedItem()).getFile().getName() +""); } iReportFont.setPdfEmbedded( this.jCheckBoxPDFEmbedded.isSelected()); if (this.jComboBoxPdfEncoding.getSelectedItem() instanceof PdfEncoding) iReportFont.setPdfEncoding( ((PdfEncoding)this.jComboBoxPdfEncoding.getSelectedItem()).getEncoding()); else iReportFont.setPdfEncoding( Misc.nvl(this.jComboBoxPdfEncoding.getSelectedItem(),"CP1251")); iReportFont.setStrikeTrought( this.jCheckBoxStrokeTrough.isSelected()); iReportFont.setTTFFont( Misc.nvl(this.jComboBoxTTFFont.getSelectedItem(),"") ); iReportFont.setUnderline( this.jCheckBoxUnderline.isSelected()); /* tmpParameter = new JRParameter( this.jTextFieldName.getText(), "java.lang.String", this.jCheckBoxIsForPrompting.isSelected(), this.jTextAreaDescription.getText()); if (this.jComboBoxType.getSelectedItem().toString().trim().length() != 0) { tmpParameter.setClassType( this.jComboBoxType.getSelectedItem().toString().trim() ); } tmpParameter.setDefaultValueExpression( jRTextExpressionAreaDefaultExpression.getText());*/ setVisible(false); this.setDialogResult( javax.swing.JOptionPane.OK_OPTION); dispose(); }//GEN-LAST:event_jButtonOKActionPerformed /** Closes the dialog */ private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog setVisible(false); this.setDialogResult( javax.swing.JOptionPane.CLOSED_OPTION); dispose(); }//GEN-LAST:event_closeDialog /** * @param args the command line arguments */ public static void main(String args[]) { new JRParameterDialog(new javax.swing.JFrame(), true).show(); } /** Getter for property dialogResult. * @return Value of property dialogResult. * */ public int getDialogResult() { return dialogResult; } /** Setter for property dialogResult. * @param dialogResult New value of property dialogResult. * */ public void setDialogResult(int dialogResult) { this.dialogResult = dialogResult; } /** Getter for property iReportFont. * @return Value of property iReportFont. * */ public it.businesslogic.ireport.IReportFont getIReportFont() { return iReportFont; } /** Setter for property iReportFont. * @param iReportFont New value of property iReportFont. * */ public void setIReportFont(it.businesslogic.ireport.IReportFont iReportFont) { init = true; this.jTextFieldReportFont.setText( new String(iReportFont.getReportFont()) ); this.jCheckBoxBold.setSelected( iReportFont.isBold()); this.jCheckBoxItalic.setSelected( iReportFont.isItalic()); this.jCheckBoxStrokeTrough.setSelected( iReportFont.isStrikeTrought()); this.jCheckBoxPDFEmbedded.setSelected( iReportFont.isPdfEmbedded() ); this.jCheckBoxUnderline.setSelected( iReportFont.isUnderline()); setComboBoxText(true, iReportFont.getFontName() , jComboBoxFontName); if (iReportFont.getPDFFontName().toUpperCase().endsWith(".TTF")) { this.setComboBoxText(true, "External TTF font..." , jComboBoxPDFFontName ); this.jComboBoxTTFFont.setEnabled(true); this.jLabelTTF.setEnabled(true); } else this.setComboBoxText(true, iReportFont.getPDFFontName() , jComboBoxPDFFontName ); if (iReportFont.getPDFFontName().toUpperCase().endsWith(".TTF")) { jComboBoxTTFFont.setEnabled(true); jLabelTTF.setEnabled(true); this.setFontComboBox(true, iReportFont.getPDFFontName() , jComboBoxTTFFont ); } else { jComboBoxTTFFont.setEnabled(false); jLabelTTF.setEnabled(false); } this.setElementComboNumber(true, iReportFont.getFontSize() , jNumberComboBoxSize ); this.setPdfEncodingComboBox(true, iReportFont.getPdfEncoding() , jComboBoxPdfEncoding ); init = false; } public void updateFonts(Vector iRFonts) { Misc.updateComboBox( jComboBoxTTFFont, iRFonts, false); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton jButtonCancel; private javax.swing.JButton jButtonOK; private javax.swing.JCheckBox jCheckBoxBold; private javax.swing.JCheckBox jCheckBoxItalic; private javax.swing.JCheckBox jCheckBoxPDFEmbedded; private javax.swing.JCheckBox jCheckBoxStrokeTrough; private javax.swing.JCheckBox jCheckBoxUnderline; private javax.swing.JComboBox jComboBoxFontName; private javax.swing.JComboBox jComboBoxPDFFontName; private javax.swing.JComboBox jComboBoxPdfEncoding; private javax.swing.JComboBox jComboBoxTTFFont; private javax.swing.JLabel jLabel23; private javax.swing.JLabel jLabel24; private javax.swing.JLabel jLabel25; private javax.swing.JLabel jLabel27; private javax.swing.JLabel jLabel32; private javax.swing.JLabel jLabelTTF; private it.businesslogic.ireport.gui.JNumberComboBox jNumberComboBoxSize; private javax.swing.JPanel jPanelFont; private javax.swing.JSeparator jSeparator2; private javax.swing.JSeparator jSeparator3; private javax.swing.JTextField jTextFieldReportFont; // End of variables declaration//GEN-END:variables private int dialogResult; protected boolean setComboBoxText( boolean firstTime, String value, javax.swing.JComboBox comboField ) { if (( ! firstTime ) && (!( Misc.nvl(comboField.getSelectedItem(),"").equalsIgnoreCase(value)))) { comboField.setSelectedIndex(0); return false; } else { try { comboField.setSelectedItem( value ); } catch (Exception ex){ ex.printStackTrace(); } } return true; } protected boolean setFontComboBox( boolean firstTime, String value, javax.swing.JComboBox comboField ) { if (( ! firstTime ) && (!(comboField.getSelectedItem()!=null && comboField.getSelectedItem() instanceof IRFont && ((IRFont)comboField.getSelectedItem()).getFile().equals(value)))) { if (comboField.getItemCount() > 0) comboField.setSelectedIndex(0); return false; } else { try { for (int i=0; i<comboField.getItemCount(); ++i) { if (comboField.getItemAt(i) instanceof IRFont && ((IRFont)comboField.getItemAt(i)).getFile().getName().equals(value) ) { comboField.setSelectedIndex(i); return true; } } if (comboField.getItemCount() > 0) comboField.setSelectedIndex(0); } catch (Exception ex){ ex.printStackTrace(); } } return true; } protected boolean setPdfEncodingComboBox( boolean firstTime, String value, javax.swing.JComboBox comboField ) { if (( ! firstTime ) && (!(comboField.getSelectedItem()!=null && ( (comboField.getSelectedItem() instanceof PdfEncoding && ((PdfEncoding)comboField.getSelectedItem()).getEncoding().equalsIgnoreCase(value)) || (comboField.getSelectedItem()+"").equals(value) )))) { if (comboField.getItemCount() > 0) comboField.setSelectedIndex(0); return false; } else { try { for (int i=0; i<comboField.getItemCount(); ++i) { if (comboField.getItemAt(i) instanceof PdfEncoding && ((PdfEncoding)comboField.getItemAt(i)).getEncoding().equals(value) ) { comboField.setSelectedIndex(i); return true; } } comboField.setSelectedItem(value); } catch (Exception ex){ ex.printStackTrace(); } } return true; } protected boolean setElementComboNumber( boolean firstTime, double value, JNumberComboBox numberField ) { if (( ! firstTime ) && (!(numberField.getValue() == value))) { numberField.setSelectedItem(""); return false; } else { try { numberField.setValue( value ); } catch (Exception ex){ ex.printStackTrace(); } } return true; }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?