1 package org.lucane.applications.jmail.base; 2 3 22 23 import java.io.*; 24 import javax.mail.*; 25 import javax.mail.internet.*; 26 import javax.swing.*; 27 28 29 final class MessageSourceFrame extends JFrame 30 { 31 private Message msg; 32 33 private JPanel panel; 34 private JTextArea area; 35 private JScrollPane scrollPane; 36 37 41 protected MessageSourceFrame(String subject, Message msg) 42 { 43 super(subject); 44 45 this.msg = msg; 46 47 panel = new JPanel(); 48 49 area = new JTextArea(); 50 area.setEditable(false); 51 fillArea(); 52 area.setCaretPosition(0); 53 54 area.setRows(30); 55 area.setColumns(40); 56 57 scrollPane = new JScrollPane(area, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); 58 panel.add(scrollPane); 59 60 setContentPane(panel); 61 62 setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); 63 64 pack(); 65 setResizable(false); 66 setVisible(true); 67 } 68 69 70 private void fillArea() 71 { 72 try 73 { 74 String fileName = ((MimeMessage)msg).getMessageID(); 75 fileName = fileName.substring(1, 10); 76 77 File file = File.createTempFile(fileName, null); 78 79 FileOutputStream out = new FileOutputStream(file); 80 msg.writeTo(out); 81 out.close(); 82 83 BufferedReader in = new BufferedReader(new FileReader(file)); 84 85 String line = new String (); 86 87 while((line = in.readLine()) != null) 88 area.append(line + "\n"); 89 90 in.close(); 91 92 file.delete(); 93 } 94 95 catch(Exception e) 96 { 97 e.printStackTrace(); 98 } 99 } 100 } 101 | Popular Tags |