View Javadoc

1   package helloagain.kanday;
2   
3   import java.awt.BorderLayout;
4   import java.awt.Color;
5   import java.awt.Frame;
6   import java.awt.event.ActionEvent;
7   import java.awt.event.ActionListener;
8   import java.awt.event.WindowAdapter;
9   import java.awt.event.WindowEvent;
10  import java.util.logging.Level;
11  import java.util.logging.Logger;
12  import javax.swing.Icon;
13  import javax.swing.JButton;
14  import javax.swing.JDialog;
15  import javax.swing.JLabel;
16  import javax.swing.JPanel;
17  
18  /***
19   * プログラム情報を表示するダイアログ。
20   * プログラムのイメージと、簡単な説明文、コピーライト表示、
21   * プログラムのバージョン表示を行う。
22   * <p>
23   * Created: Wed Jun 02 18:36:17 2004
24   *
25   * @author <a href="mailto:torutk@02.246.ne.jp">TAKAHASHI,Toru</a>
26   * @version 1.0
27   */
28  public class KandayAboutDialog extends JDialog {
29  
30      /***
31       * プログラム情報を表示するダイアログを生成する。
32       * @param anOwner このダイアログの親となるフレーム
33       * @param aTitle ダイアログのタイトルバーに表示する文字列
34       * @param anIcon ダイアログの画像
35       * @param aDescription プログラムの説明文
36       * @param aVersion プログラムのバージョン識別子
37       * @param aCopyright プログラムの著作権表記
38       */
39      public KandayAboutDialog(
40          Frame anOwner, String aTitle, Icon anIcon, String aDescription,
41          String aVersion, String aCopyright
42      ) {
43          super(anOwner, aTitle, true);
44          if (logger.isLoggable(Level.FINER)) {
45              logger.entering(
46                  MYCLASS, "KandayAboutDialog",
47                  new Object[] {anOwner, aTitle, anIcon, aDescription,
48                                aVersion, aCopyright }
49              );
50          }
51          getContentPane().setBackground(Color.WHITE);
52          JLabel imageLabel = new JLabel(anIcon);
53          getContentPane().add(imageLabel, BorderLayout.NORTH);
54          String message = "<html><center>" + aDescription + "<br>Version : " +
55              aVersion + "<br>" + aCopyright + "</center></html>";
56          JLabel messageLabel = new JLabel(message, JLabel.CENTER);
57          getContentPane().add(messageLabel, BorderLayout.CENTER);
58  
59          final JButton okButton = new JButton("OK");
60          okButton.addActionListener(new ActionListener() {
61                  public void actionPerformed(ActionEvent ev) {
62                      dispose();
63                  }
64              });
65          JPanel panel = new JPanel();
66          panel.setBackground(Color.WHITE);
67          panel.add(okButton);
68          getContentPane().add(panel, BorderLayout.SOUTH);
69  
70          // ダイアログが表示された時に、[OK]ボタンにフォーカスを設定
71          addWindowListener(new WindowAdapter() {
72                  public void windowOpened(WindowEvent ev) {
73                      okButton.requestFocus();
74                  }
75              });
76  
77          pack();
78          setResizable(false);
79          setLocationRelativeTo(anOwner);
80              logger.exiting(MYCLASS, "KandayAboutDialog");
81      }
82      private static final String MYCLASS = KandayAboutDialog.class.getName();
83      private static Logger logger = Logger.getLogger(MYCLASS);
84  }