1 6 7 package it.businesslogic.ireport.gui.fonts; 8 9 import it.businesslogic.ireport.FontsLoaderMonitor; 10 import java.lang.reflect.InvocationTargetException ; 11 import javax.swing.SwingUtilities ; 12 import it.businesslogic.ireport.util.I18n; 13 14 18 public class FontLoaderDialog extends javax.swing.JDialog implements FontsLoaderMonitor { 19 20 21 public FontLoaderDialog(java.awt.Frame parent, boolean modal) { 22 super(parent, modal); 23 initComponents(); 24 applyI18n(); 25 this.pack(); 26 27 it.businesslogic.ireport.util.Misc.centerFrame( this ); 28 } 29 30 35 private void initComponents() { 37 java.awt.GridBagConstraints gridBagConstraints; 38 39 jLabelStatus = new javax.swing.JLabel (); 40 41 getContentPane().setLayout(new java.awt.GridBagLayout ()); 42 43 setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); 44 jLabelStatus.setText("Loading status"); 45 jLabelStatus.setVerticalAlignment(javax.swing.SwingConstants.TOP); 46 jLabelStatus.setPreferredSize(new java.awt.Dimension (391, 51)); 47 gridBagConstraints = new java.awt.GridBagConstraints (); 48 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 49 gridBagConstraints.weightx = 1.0; 50 gridBagConstraints.weighty = 1.0; 51 gridBagConstraints.insets = new java.awt.Insets (4, 4, 4, 4); 52 getContentPane().add(jLabelStatus, gridBagConstraints); 53 54 pack(); 55 } 57 60 public static void main(String args[]) { 61 java.awt.EventQueue.invokeLater(new Runnable () { 62 public void run() { 63 new FontLoaderDialog(new javax.swing.JFrame (), true).setVisible(true); 64 } 65 }); 66 } 67 68 public void setStatus(String s) 69 { 70 jLabelStatus.setText(s); 71 } 72 73 public void fontsLoadingStatusUpdated(String statusMsg) { 74 75 final String s = statusMsg; 76 try { 77 SwingUtilities.invokeAndWait( new Runnable () 78 { 79 public void run() 80 { 81 setStatus(s); 82 } 83 } 84 ); 85 } catch (InterruptedException ex) { 86 ex.printStackTrace(); 87 } catch (InvocationTargetException ex) { 88 ex.printStackTrace(); 89 } 90 91 } 92 93 public void fontsLoadingStarted() { 94 95 try { 96 SwingUtilities.invokeAndWait( new Runnable () 97 { 98 public void run() 99 { 100 setVisible(true); 101 } 102 } 103 ); 104 } catch (InterruptedException ex) { 105 ex.printStackTrace(); 106 } catch (InvocationTargetException ex) { 107 ex.printStackTrace(); 108 } 109 } 110 111 public void fontsLoadingFinished() { 112 try { 113 SwingUtilities.invokeAndWait( new Runnable () 114 { 115 public void run() 116 { 117 setVisible(false); 118 } 119 } 120 ); 121 } catch (InterruptedException ex) { 122 ex.printStackTrace(); 123 } catch (InvocationTargetException ex) { 124 ex.printStackTrace(); 125 } 126 } 127 128 private javax.swing.JLabel jLabelStatus; 130 132 public void applyI18n(){ 133 jLabelStatus.setText(I18n.getString("fontLoaderDialog.labelStatus","Loading status")); 135 } 137 } 138 | Popular Tags |