1 32 33 package it.businesslogic.ireport.gui.sheet; 34 35 import it.businesslogic.ireport.IReportFont; 36 import it.businesslogic.ireport.gui.JRFontDialog; 37 import it.businesslogic.ireport.gui.MainFrame; 38 import it.businesslogic.ireport.util.I18n; 39 40 44 public class FontSheetPropertyComponent extends javax.swing.JPanel { 45 46 String expression = ""; 47 private java.awt.Font font = null; 48 private IReportFont ireportFont = null; 49 50 51 public FontSheetPropertyComponent() { 52 initComponents(); 53 font = jLabelFont.getFont(); 54 applyI18n(); 55 } 56 57 public void fontChanged() 58 { 59 java.awt.event.ActionEvent event = new java.awt.event.ActionEvent (this,0,""); 60 fireActionListenerActionPerformed(event); 61 } 62 63 68 private void initComponents() { 70 java.awt.GridBagConstraints gridBagConstraints; 71 72 jLabelFont = new javax.swing.JLabel (); 73 jButton1 = new javax.swing.JButton (); 74 75 setLayout(new java.awt.GridBagLayout ()); 76 77 setBackground(new java.awt.Color (255, 255, 255)); 78 jLabelFont.setBackground(new java.awt.Color (255, 255, 255)); 79 jLabelFont.setOpaque(true); 80 gridBagConstraints = new java.awt.GridBagConstraints (); 81 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 82 gridBagConstraints.weightx = 1.0; 83 gridBagConstraints.weighty = 1.0; 84 gridBagConstraints.insets = new java.awt.Insets (0, 4, 0, 0); 85 add(jLabelFont, gridBagConstraints); 86 87 jButton1.setText("..."); 88 jButton1.setMaximumSize(new java.awt.Dimension (19, 10)); 89 jButton1.setMinimumSize(new java.awt.Dimension (19, 10)); 90 jButton1.setPreferredSize(new java.awt.Dimension (19, 10)); 91 jButton1.addActionListener(new java.awt.event.ActionListener () { 92 public void actionPerformed(java.awt.event.ActionEvent evt) { 93 jButton1ActionPerformed(evt); 94 } 95 }); 96 97 gridBagConstraints = new java.awt.GridBagConstraints (); 98 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 99 gridBagConstraints.weighty = 1.0; 100 add(jButton1, gridBagConstraints); 101 102 } 104 private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { 106 107 it.businesslogic.ireport.gui.JRFontDialog jrfd = new it.businesslogic.ireport.gui.JRFontDialog(MainFrame.getMainInstance(), true); 108 109 jrfd.updateFonts( it.businesslogic.ireport.gui.MainFrame.getMainInstance().getTtfFonts()); 110 jrfd.setReportFontMode(fontMode); 111 if (ireportFont != null) 112 { 113 jrfd.setIReportFont( (IReportFont)ireportFont.clone() ); 114 } 115 else 116 { 117 jrfd.setIReportFont( new IReportFont() ); 118 } 119 120 jrfd.setVisible(true); 121 if (jrfd.getDialogResult() == javax.swing.JOptionPane.OK_OPTION) 122 { 123 setIreportFont( jrfd.getIReportFont() ); 124 fontChanged(); 125 } 126 127 } 129 130 private javax.swing.JButton jButton1; 132 private javax.swing.JLabel jLabelFont; 133 135 138 private javax.swing.event.EventListenerList listenerList = null; 139 140 144 public synchronized void addActionListener(java.awt.event.ActionListener listener) { 145 146 if (listenerList == null ) { 147 listenerList = new javax.swing.event.EventListenerList (); 148 } 149 listenerList.add (java.awt.event.ActionListener .class, listener); 150 } 151 152 156 public synchronized void removeActionListener(java.awt.event.ActionListener listener) { 157 158 listenerList.remove (java.awt.event.ActionListener .class, listener); 159 } 160 161 166 private void fireActionListenerActionPerformed(java.awt.event.ActionEvent event) { 167 168 if (listenerList == null) return; 169 Object [] listeners = listenerList.getListenerList (); 170 for (int i = listeners.length - 2; i >= 0; i -= 2) { 171 if (listeners[i]==java.awt.event.ActionListener .class) { 172 ((java.awt.event.ActionListener )listeners[i+1]).actionPerformed (event); 173 } 174 } 175 } 176 177 public IReportFont getIreportFont() { 178 return ireportFont; 179 } 180 181 public void setIreportFont(IReportFont ireportFont) { 182 this.ireportFont = ireportFont; 183 184 185 if (ireportFont == null) ireportFont = new IReportFont(); 186 187 jLabelFont.setFont(ireportFont.getJavaAWTFont()); 188 String bold = (ireportFont.isBold() ? " bold" : ""); 189 jLabelFont.setText(ireportFont.getFontName() + " " + ireportFont.getFontSize() + bold); 190 191 } 192 193 private int fontMode = 0; 197 public int getFontMode() { 198 return fontMode; 199 } 200 201 public void setFontMode(int fontMode) { 202 this.fontMode = fontMode; 203 } 204 205 public void applyI18n(){ 206 jButton1.setText(I18n.getString("fontSheetPropertyComponent.button1","...")); 208 } 210 } 211 | Popular Tags |