OSDN Git Service

Merge branch 'master' of ssh://www.deister.jp/mnt/hdb1/git/hayashi
[hayashilib/hayashi.git] / src / hayashi / yuu / tools / mail / gui / SendMailGUI.java
index 8ba4b60..e062056 100644 (file)
-package hayashi.yuu.tools.mail.gui;
-
-import hayashi.yuu.tools.logger.LoggerFactory;
-import hayashi.yuu.tools.mail.SendMail;
-import hayashi.yuu.tools.mail.SiteData;
-import hayashi.yuu.tools.properties.Encrypt;
-
-import java.awt.*;
-import java.awt.event.*;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.util.logging.Logger;
-
-import javax.swing.JFrame;
-import javax.swing.JLabel;
-import javax.swing.JMenu;
-import javax.swing.JMenuBar;
-import javax.swing.JMenuItem;
-import javax.swing.JPanel;
-import javax.swing.JScrollPane;
-import javax.swing.JTextArea;
-import javax.swing.WindowConstants;
-
-
-@SuppressWarnings("serial")
-public class SendMailGUI extends JFrame implements ActionListener
-{
-    public static SendMailGUI mainFrame;
-    boolean fComponentsAdjusted;
-    JPanel headPanel;
-    JMenuBar mainMenuBar;      // [メニュー]
-    JMenu menuFile;                    // [メニュー]->[ファイル(F)]
-    JMenuItem miSetting;       // [メニュー]->[ファイル(F)]->[設定...]
-    JMenuItem miExit;          // [メニュー]->[ファイル(F)]->[終了(X)]
-    
-    public Logger logger;
-    public static SiteData mailProp;
-    public static String propertiesFileName;
-    
-    /**
-     * 「メール送信(SendMail)」
-     * 起動オプション:
-     *  第一: メールアカウントの設定ファイル名
-     */
-    public static void main(String args[]) throws Exception {
-               String fileName = "sendmail.properties";
-       if (args.length > 0) {
-               fileName = args[0];
-       }
-        (new SendMailGUI(fileName)).setVisible(true);
-    }
-    
-    public SendMailGUI(String propertiesName) throws Exception {
-       Encrypt.PASSWORD_KEY = "hayashihimitukagi";
-        logger = LoggerFactory.getInstance();  // Loggerオブジェクトの生成
-       SendMailGUI.propertiesFileName = propertiesName;
-        SendMailGUI.mailProp = new SiteData(SendMailGUI.propertiesFileName);
-
-        // ログ出力
-        logger.info("SendMailGUI - プログラム起動");
-        
-        // 初期設定
-        fComponentsAdjusted = false;
-        setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
-        Container container = getContentPane();
-        container.setLayout(new BorderLayout());
-        setTitle("SendMail GUI");
-        
-        mainFrame = this;
-        
-        // [メニュー]->[ファイル(F)]
-        menuFile = new JMenu("ファイル(F)");
-        menuFile.setMnemonic('F');
-        menuFile.setFont(new Font("Dialog", 0, 12));
-        
-        // [メニュー]->[ファイル(F)]->[設定...]
-        miSetting = new JMenuItem("設定...");
-        miSetting.addActionListener(this);
-        miSetting.setFont(new Font("Dialog", 0, 12));
-        menuFile.add(miSetting);
-        
-        // [メニュー]->[ファイル(F)]->[------------]
-        menuFile.addSeparator();
-
-        // [メニュー]->[ファイル(F)]->[終了(X)]
-        miExit = new JMenuItem("終了(X)");
-        miExit.addActionListener(this);
-        miExit.setMnemonic('X');
-        miExit.setFont(new Font("Dialog", 0, 12));
-        menuFile.add(miExit);
-        
-        // [メニュー]
-        mainMenuBar = new JMenuBar();
-        mainMenuBar.add(menuFile);
-        getRootPane().setJMenuBar(mainMenuBar);
-
-        // 上部にヘッダパネル
-        headPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
-        getContentPane().add(BorderLayout.NORTH, headPanel);
-        JLabel label1 = new JLabel("SendMail GUI - サンプルプログラム", JLabel.CENTER);
-        label1.setBounds(10,10,340,20);
-        
-        // 中央に、メインパネルを配置
-        JPanel mainPanel = new JPanel(new FlowLayout());
-        //mainPanel.setPreferredSize(new Dimension(500, 400));
-        getContentPane().add(mainPanel, BorderLayout.CENTER);
-        
-        JTextArea textArea = new JTextArea(20, 60);
-        textArea.setEditable(false);
-        textArea.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 12));
-               textArea.append("メール送信設定 サンプルプログラム\n");
-               textArea.setCaretPosition(0);
-               JScrollPane scrollPane = new JScrollPane(textArea);
-               scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
-               mainPanel.add(scrollPane, BorderLayout.CENTER);
-        
-        // 下部にコピーライトを配置
-        JPanel southPanel = new JPanel(new FlowLayout());
-        getContentPane().add(BorderLayout.SOUTH, southPanel);
-        
-        JLabel label2 = new JLabel("All rights reserved.Copyright(c) 2010,, Hayashi,Yuu.", JLabel.CENTER);
-        label2.setBounds(10,40,340,20);
-        southPanel.add(label2);
-        
-               pack();
-               setLocationRelativeTo(null);
-               setVisible(true);
-    }
-    
-    public SendMail getMailInstance() {
-               return new SendMail(SendMailGUI.mailProp);
-    }
-    
-    public static String getPropertiesFileName() {
-       return propertiesFileName;
-    }
-
-       public void addNotify() {
-        Dimension d = getSize();
-        super.addNotify();
-        if (fComponentsAdjusted) {
-            return;
-        }
-        setSize(getInsets().left + getInsets().right + d.width, getInsets().top + getInsets().bottom + d.height);
-        Component components[] = getComponents();
-        for (int i = 0; i < components.length; i++) {
-            Point p = components[i].getLocation();
-            p.translate(getInsets().left, getInsets().top);
-            components[i].setLocation(p);
-        }
-
-        fComponentsAdjusted = true;
-    }
-
-       /**
-        * [メニュー]アクション: 
-        * @param event
-        */
-       public void actionPerformed(ActionEvent event) {
-        Object object = event.getSource();
-        if(object == miExit) {
-            miExit_Action(event);
-        }
-        else if (object == miSetting) {
-            miSetting_Action(event);
-        }
-    }
-       
-    /**
-     * アクション:
-     * [メニュー]->[ファイル]->[終了]
-     * 
-     * @param event
-     */
-    void miExit_Action(ActionEvent event) {
-       setVisible(false);
-        logger.info("SendMailGUI - プログラム終了");
-        System.exit(0);
-    }
-
-    /**
-     * アクション:
-     * [メニュー]->[ファイル]->[設定...]
-     * 
-     * @param event
-     */
-    void miSetting_Action(ActionEvent event) {
-        try {
-                       (new SettingDialog(this, true, SendMailGUI.getPropertiesFileName(), logger)).setVisible(true);
-               }
-        catch (FileNotFoundException e) {
-                       // 回復不能な重大なエラー
-                       e.printStackTrace();
-               }
-        catch (IOException e) {
-                       // 回復不能な重大なエラー
-                       e.printStackTrace();
-               }
-    }
-}
+package hayashi.yuu.tools.mail.gui;\r
+\r
+import hayashi.yuu.tools.logger.LoggerFactory;\r
+import hayashi.yuu.tools.mail.SendMail;\r
+import hayashi.yuu.tools.mail.SiteData;\r
+import hayashi.yuu.tools.properties.Encrypt;\r
+\r
+import java.awt.*;\r
+import java.awt.event.*;\r
+import java.io.FileNotFoundException;\r
+import java.io.IOException;\r
+import java.util.logging.Logger;\r
+\r
+import javax.swing.JFrame;\r
+import javax.swing.JLabel;\r
+import javax.swing.JMenu;\r
+import javax.swing.JMenuBar;\r
+import javax.swing.JMenuItem;\r
+import javax.swing.JPanel;\r
+import javax.swing.JScrollPane;\r
+import javax.swing.JTextArea;\r
+import javax.swing.WindowConstants;\r
+\r
+\r
+@SuppressWarnings("serial")\r
+public class SendMailGUI extends JFrame implements ActionListener\r
+{\r
+    public static SendMailGUI mainFrame;\r
+    boolean fComponentsAdjusted;\r
+    JPanel headPanel;\r
+    JMenuBar mainMenuBar;      // [メニュー]\r
+    JMenu menuFile;                    // [メニュー]->[ファイル(F)]\r
+    JMenuItem miSetting;       // [メニュー]->[ファイル(F)]->[設定...]\r
+    JMenuItem miExit;          // [メニュー]->[ファイル(F)]->[終了(X)]\r
+    \r
+    public Logger logger;\r
+    public static SiteData mailProp;\r
+    public static String propertiesFileName;\r
+    \r
+    /**\r
+     * 「メール送信(SendMail)」\r
+     * 起動オプション:\r
+     *  第一: メールアカウントの設定ファイル名\r
+     */\r
+    public static void main(String args[]) throws Exception {\r
+               String fileName = "sendmail.properties";\r
+       if (args.length > 0) {\r
+               fileName = args[0];\r
+       }\r
+        (new SendMailGUI(fileName)).setVisible(true);\r
+    }\r
+    \r
+    public SendMailGUI(String propertiesName) throws Exception {\r
+       Encrypt.PASSWORD_KEY = "hayashihimitukagi";\r
+        logger = LoggerFactory.getInstance();  // Loggerオブジェクトの生成\r
+       SendMailGUI.propertiesFileName = propertiesName;\r
+        SendMailGUI.mailProp = new SiteData(SendMailGUI.propertiesFileName);\r
+\r
+        // ログ出力\r
+        logger.info("SendMailGUI - プログラム起動");\r
+        \r
+        // 初期設定\r
+        fComponentsAdjusted = false;\r
+        setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);\r
+        Container container = getContentPane();\r
+        container.setLayout(new BorderLayout());\r
+        setTitle("SendMail GUI");\r
+        \r
+        mainFrame = this;\r
+        \r
+        // [メニュー]->[ファイル(F)]\r
+        menuFile = new JMenu("ファイル(F)");\r
+        menuFile.setMnemonic('F');\r
+        menuFile.setFont(new Font("Dialog", 0, 12));\r
+        \r
+        // [メニュー]->[ファイル(F)]->[設定...]\r
+        miSetting = new JMenuItem("設定...");\r
+        miSetting.addActionListener(this);\r
+        miSetting.setFont(new Font("Dialog", 0, 12));\r
+        menuFile.add(miSetting);\r
+        \r
+        // [メニュー]->[ファイル(F)]->[------------]\r
+        menuFile.addSeparator();\r
+\r
+        // [メニュー]->[ファイル(F)]->[終了(X)]\r
+        miExit = new JMenuItem("終了(X)");\r
+        miExit.addActionListener(this);\r
+        miExit.setMnemonic('X');\r
+        miExit.setFont(new Font("Dialog", 0, 12));\r
+        menuFile.add(miExit);\r
+        \r
+        // [メニュー]\r
+        mainMenuBar = new JMenuBar();\r
+        mainMenuBar.add(menuFile);\r
+        getRootPane().setJMenuBar(mainMenuBar);\r
+\r
+        // 上部にヘッダパネル\r
+        headPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));\r
+        getContentPane().add(BorderLayout.NORTH, headPanel);\r
+        JLabel label1 = new JLabel("SendMail GUI - サンプルプログラム", JLabel.CENTER);\r
+        label1.setBounds(10,10,340,20);\r
+        \r
+        // 中央に、メインパネルを配置\r
+        JPanel mainPanel = new JPanel(new FlowLayout());\r
+        //mainPanel.setPreferredSize(new Dimension(500, 400));\r
+        getContentPane().add(mainPanel, BorderLayout.CENTER);\r
+        \r
+        JTextArea textArea = new JTextArea(20, 60);\r
+        textArea.setEditable(false);\r
+        textArea.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 12));\r
+               textArea.append("メール送信設定 サンプルプログラム\n");\r
+               textArea.setCaretPosition(0);\r
+               JScrollPane scrollPane = new JScrollPane(textArea);\r
+               scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);\r
+               mainPanel.add(scrollPane, BorderLayout.CENTER);\r
+        \r
+        // 下部にコピーライトを配置\r
+        JPanel southPanel = new JPanel(new FlowLayout());\r
+        getContentPane().add(BorderLayout.SOUTH, southPanel);\r
+        \r
+        JLabel label2 = new JLabel("All rights reserved.Copyright(c) 2010,, Hayashi,Yuu.", JLabel.CENTER);\r
+        label2.setBounds(10,40,340,20);\r
+        southPanel.add(label2);\r
+        \r
+               pack();\r
+               setLocationRelativeTo(null);\r
+               setVisible(true);\r
+    }\r
+    \r
+    public SendMail getMailInstance() {\r
+               return new SendMail(SendMailGUI.mailProp);\r
+    }\r
+    \r
+    public static String getPropertiesFileName() {\r
+       return propertiesFileName;\r
+    }\r
+\r
+       public void addNotify() {\r
+        Dimension d = getSize();\r
+        super.addNotify();\r
+        if (fComponentsAdjusted) {\r
+            return;\r
+        }\r
+        setSize(getInsets().left + getInsets().right + d.width, getInsets().top + getInsets().bottom + d.height);\r
+        Component components[] = getComponents();\r
+        for (int i = 0; i < components.length; i++) {\r
+            Point p = components[i].getLocation();\r
+            p.translate(getInsets().left, getInsets().top);\r
+            components[i].setLocation(p);\r
+        }\r
+\r
+        fComponentsAdjusted = true;\r
+    }\r
+\r
+       /**\r
+        * [メニュー]アクション: \r
+        * @param event\r
+        */\r
+       public void actionPerformed(ActionEvent event) {\r
+        Object object = event.getSource();\r
+        if(object == miExit) {\r
+            miExit_Action(event);\r
+        }\r
+        else if (object == miSetting) {\r
+            miSetting_Action(event);\r
+        }\r
+    }\r
+       \r
+    /**\r
+     * アクション:\r
+     * [メニュー]->[ファイル]->[終了]\r
+     * \r
+     * @param event\r
+     */\r
+    void miExit_Action(ActionEvent event) {\r
+       setVisible(false);\r
+        logger.info("SendMailGUI - プログラム終了");\r
+        System.exit(0);\r
+    }\r
+\r
+    /**\r
+     * アクション:\r
+     * [メニュー]->[ファイル]->[設定...]\r
+     * \r
+     * @param event\r
+     */\r
+    void miSetting_Action(ActionEvent event) {\r
+        try {\r
+                       (new SettingDialog(this, true, SendMailGUI.getPropertiesFileName(), logger)).setVisible(true);\r
+               }\r
+        catch (FileNotFoundException e) {\r
+                       // 回復不能な重大なエラー\r
+                       e.printStackTrace();\r
+               }\r
+        catch (IOException e) {\r
+                       // 回復不能な重大なエラー\r
+                       e.printStackTrace();\r
+               }\r
+    }\r
+}\r