commons.java subversion repository

sventon subversion web client - http://www.sventon.org
[show recent changes]
 
  Help
HEAD
Rev: 669 - https://secure.bioinfweb.info/Code/svn/commons.java / trunk / main / info.bioinfweb.commons.swing / src / info / bioinfweb / commons / swing / AboutDialog.java
Show File - AboutDialog.java  [show properties]
spinner
/*
 * bioinfweb.commons.java - Shared components of bioinfweb projects made available in a Java library
 * Copyright (C) 2008-2011, 2013-2018  Ben Stöver, Sarah Wiechers
 * <http://commons.bioinfweb.info/Java>
 * 
 * This file is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
10   * 
11   * This file is distributed in the hope that it will be useful,
12   * but WITHOUT ANY WARRANTY; without even the implied warranty of
13   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14   * GNU Lesser General Public License for more details.
15   * 
16   * You should have received a copy of the GNU Lesser General Public License
17   * along with this program. If not, see <http://www.gnu.org/licenses/>.
18   */
19  package info.bioinfweb.commons.swing;
20 
21 
22  import java.awt.Component;
23  import java.awt.Dialog;
24  import java.awt.Frame;
25  import java.awt.GraphicsConfiguration;
26  import java.awt.GridBagConstraints;
27  import java.awt.GridBagLayout;
28  import java.awt.Insets;
29  import java.awt.Window;
30 
31  import javax.swing.BoxLayout;
32  import javax.swing.Icon;
33  import javax.swing.JButton;
34  import javax.swing.JDialog;
35  import javax.swing.JEditorPane;
36  import javax.swing.JPanel;
37  import javax.swing.JScrollPane;
38  import javax.swing.JTabbedPane;
39  import javax.swing.event.HyperlinkListener;
40 
41 
42 
43  /**
44   * A customizable about dialog that contains information in mutliple tabs.
45   * <p>
46   * To Inherited classes should add their tabs using {@link #addTab(String, Icon, Component, String)}, 
47   * {@link #addTab(String, Icon, String, String, String)} or {@link #addScrolledTab(String, Icon, Component, String)}.
48   * 
49   * @author Ben St&ouml;ver
50   * @since 3.3.0
51   */
52  public class AboutDialog extends JDialog {
53      private static final long serialVersionUID = 1L;
54      
55      private JPanel jContentPane = null;
56      private JTabbedPane tabbedPane;
57      private JPanel buttonPanel = null;
58      private JButton closeButton = null;
59      private HyperlinkListener hyperlinkListener = new SystemBrowserHyperlinkListener(this);
60      
61      
62      public AboutDialog(Dialog owner, boolean modal) {
63          super(owner, modal);
64          init();
65      }
66 
67 
68      public AboutDialog(Dialog owner, String title, boolean modal, GraphicsConfiguration gc) {
69          super(owner, title, modal, gc);
70          init();
71      }
72 
73 
74      public AboutDialog(Dialog owner, String title, boolean modal) {
75          super(owner, title, modal);
76          init();
77      }
78 
79 
80      public AboutDialog(Dialog owner, String title) {
81          super(owner, title);
82          init();
83      }
84 
85 
86      public AboutDialog(Dialog owner) {
87          super(owner);
88          init();
89      }
90 
91 
92      public AboutDialog(Frame owner, boolean modal) {
93          super(owner, modal);
94          init();
95      }
96 
97 
98      public AboutDialog(Frame owner, String title, boolean modal, GraphicsConfiguration gc) {
99          super(owner, title, modal, gc);
100          init();
101      }
102 
103 
104      public AboutDialog(Frame owner, String title, boolean modal) {
105          super(owner, title, modal);
106          init();
107      }
108 
109 
110      public AboutDialog(Frame owner, String title) {
111          super(owner, title);
112          init();
113      }
114 
115 
116      public AboutDialog(Frame owner) {
117          super(owner);
118          init();
119      }
120 
121 
122      public AboutDialog(Window owner, ModalityType modalityType) {
123          super(owner, modalityType);
124          init();
125      }
126 
127 
128      public AboutDialog(Window owner, String title, ModalityType modalityType, GraphicsConfiguration gc) {
129          super(owner, title, modalityType, gc);
130          init();
131      }
132 
133 
134      public AboutDialog(Window owner, String title, ModalityType modalityType) {
135          super(owner, title, modalityType);
136          init();
137      }
138 
139 
140      public AboutDialog(Window owner, String title) {
141          super(owner, title);
142          init();
143      }
144 
145 
146      public AboutDialog(Window owner) {
147          super(owner);
148          init();
149      }
150 
151 
152      private void init() {
153          setContentPane(getJContentPane());
154          setTitle("About");
155      }
156 
157 
158      /**
159       * This method initializes jContentPane
160       * 
161       * @return javax.swing.JPanel
162       */
163      private JPanel getJContentPane() {
164          if (jContentPane == null) {
165              jContentPane = new JPanel();
166              jContentPane.setLayout(new BoxLayout(getJContentPane(), BoxLayout.Y_AXIS));
167              jContentPane.add(getTabbedPane(), null);
168              jContentPane.add(getButtonPanel(), null);
169          }
170          return jContentPane;
171      }
172 
173 
174      /**
175       * This method initializes buttonPanel  
176       *  
177       * @return javax.swing.JPanel   
178       */
179      private JPanel getButtonPanel() {
180          if (buttonPanel == null) {
181              GridBagConstraints gridBagConstraints3 = new GridBagConstraints();
182              gridBagConstraints3.insets = new Insets(3, 3, 3, 3);
183              gridBagConstraints3.weighty = 1.0;
184              gridBagConstraints3.weightx = 1.0;
185              buttonPanel = new JPanel();
186              buttonPanel.setLayout(new GridBagLayout());
187              buttonPanel.add(getCloseButton(), gridBagConstraints3);
188          }
189          return buttonPanel;
190      }
191 
192 
193      /**
194       * This method initializes closeButton  
195       *  
196       * @return javax.swing.JButton  
197       */
198      private JButton getCloseButton() {
199          if (closeButton == null) {
200              closeButton = new JButton();
201              closeButton.setText("Close");
202              closeButton.addActionListener(new java.awt.event.ActionListener() {
203                  public void actionPerformed(java.awt.event.ActionEvent e) {
204                      setVisible(false);
205                  }
206              });
207          }
208          return closeButton;
209      }
210 
211 
212      protected JTabbedPane getTabbedPane() {
213          if (tabbedPane == null) {
214              tabbedPane = new JTabbedPane();
215          }
216          return tabbedPane;
217      }
218 
219 
220      protected void addTab(String title, Icon icon, Component component, String tip) {
221          getTabbedPane().addTab(title, icon, component, tip);
222      }
223 
224 
225      protected void addScrolledTab(String title, Icon icon, Component component, String tip) {
226          addTab(title, icon, new JScrollPane(component), tip);
227      }
228      
229      
230      protected void addTab(String title, Icon icon, String contentType, String content, String tip) {
231          JEditorPane editorPane = new JEditorPane();
232          editorPane.setContentType(contentType);
233          editorPane.setText(content);            
234          editorPane.setCaretPosition(0);
235          editorPane.setEditable(false);
236          editorPane.addHyperlinkListener(hyperlinkListener);
237 
238          addScrolledTab(title, icon, editorPane, tip);
239      }
240  }


feed icon

sventon 2.5.1

bioinfweb RSS feed bioinfweb on twitter bioinfweb.commons.java on GitHub
bioinfweb - Biology & Informatics Website