1 18 package sync4j.syncclient.ipod.panels; 19 20 import java.io.File ; 21 import java.io.FileReader ; 22 import java.io.BufferedReader ; 23 import java.io.IOException ; 24 25 import java.awt.Color ; 26 import java.awt.BorderLayout ; 27 import java.awt.GridBagLayout ; 28 import java.awt.Dimension ; 29 import java.awt.event.ActionEvent ; 30 import java.awt.event.ActionListener ; 31 32 import javax.swing.JDialog ; 33 import javax.swing.JScrollPane ; 34 import javax.swing.JTextArea ; 35 import javax.swing.JPanel ; 36 import javax.swing.JButton ; 37 import javax.swing.UIManager ; 38 import javax.swing.border.*; 39 import javax.swing.SwingConstants ; 40 41 import sync4j.syncclient.ipod.MainWindow; 42 import sync4j.syncclient.ipod.utils.*; 43 44 50 public class LogPanel extends JDialog implements ActionListener , Constants { 51 52 private MainWindow mainWindow ; 54 private boolean modal = false ; 55 56 private JButton jbClose ; 57 private JScrollPane jScrollPane1; 58 private JTextArea jTextArea ; 59 private JPanel jPanel ; 60 61 63 64 public LogPanel(MainWindow mainWindow, boolean modal) { 65 super(mainWindow, modal); 66 this.mainWindow = mainWindow; 67 this.modal = modal ; 68 69 initComponents(); 70 getFileLog(); 71 } 72 73 77 private void initComponents() { 78 jbClose = new JButton () ; 79 jScrollPane1 = new JScrollPane (); 80 jTextArea = new JTextArea () ; 81 jPanel = new JPanel () ; 82 83 try { 84 UIManager.setLookAndFeel(lookAndFeel); 85 } catch(Exception e) { 86 e.printStackTrace(); 87 } 88 89 getContentPane().setLayout(new BorderLayout (1,1)); 93 setTitle(Language.getMessage(Language.LABEL_TITLE_LOGWINDOW)); 94 setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); 95 setSize(600,600); 96 setLocationRelativeTo(null); 97 setFont(font); 98 setName("logDialog"); 99 setResizable(true); 100 101 jTextArea.setEditable(false); 102 jTextArea.setFont(font); 103 jTextArea.setBackground(Color.WHITE); 104 jScrollPane1.setAutoscrolls(true); 105 jScrollPane1.setViewportView(jTextArea); 106 getContentPane().add(jScrollPane1, BorderLayout.CENTER); 107 108 jPanel.setLayout(new GridBagLayout ()); 109 jPanel.setBackground(Color.WHITE); 110 jPanel.setPreferredSize(new Dimension (400, 50)); 111 getContentPane().add(jPanel, BorderLayout.SOUTH); 112 113 jbClose.setText(Language.getMessage(Language.BT_CLOSE)); 114 jbClose.setPreferredSize(new Dimension (88, 23)); 115 jbClose.setVerticalAlignment(SwingConstants.CENTER); 116 jbClose.setHorizontalAlignment(SwingConstants.CENTER); 117 jbClose.addActionListener(this); 118 jbClose.requestFocus(true); 119 jPanel.add(jbClose); 120 } 121 122 public void actionPerformed(ActionEvent evt) { 123 removeAll(); 124 setVisible(false); 125 } 126 127 130 private void getFileLog() { 131 try { 132 File logfile = mainWindow.getFileLog(); 133 if (logfile != null) { 134 FileReader fr = new FileReader (logfile); 135 BufferedReader buf = new BufferedReader (fr); 136 137 String line = null; 138 while ((line = buf.readLine()) != null) { 139 jTextArea.append(line); 140 jTextArea.append("\n"); 141 } 142 buf.close(); 143 } 144 } catch (IOException e) { 145 e.printStackTrace(); 146 System.exit(1); 147 } 148 } 149 150 } 151 | Popular Tags |