NXvalidate  1
 All Classes Namespaces Files Functions Variables
AboutDialog.java
Go to the documentation of this file.
1  /* NeXus - Neutron & X-ray Common Data Format
2  *
3  * NeXus file validation GUI tool.
4  *
5  * Copyright (C) 2010 Stephen Rankin
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20  *
21  * For further information, see <http://www.nexusformat.org/>
22  *
23  * AboutDialog.java
24  *
25  * Created on 03-Sep-2010, 11:17:52
26  */
27 
28 package org.nexusformat.nxvalidate;
29 
30 import java.io.IOException;
31 import java.io.InputStream;
32 import java.net.URL;
33 import java.util.logging.Level;
34 import java.util.logging.Logger;
35 
40 public class AboutDialog extends javax.swing.JDialog {
41 
42  private InputStream aboutHTMLStream = null;
43  private URL aboutHTMLURL = null;
44 
46  public AboutDialog(java.awt.Frame parent, boolean modal) {
47  super(parent, modal);
48  initComponents();
49  setup();
50  }
51 
57  @SuppressWarnings("unchecked")
58  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
59  private void initComponents() {
60 
61  jPanel1 = new javax.swing.JPanel();
62  jLabel1 = new javax.swing.JLabel();
63  jButton1 = new javax.swing.JButton();
64  jScrollPane2 = new javax.swing.JScrollPane();
65  jEditorPane1 = new javax.swing.JEditorPane();
66 
67  setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
68 
69  jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/nexusformat/nxvalidate/resources/nexus.png"))); // NOI18N
70  jLabel1.setToolTipText("http://www.nexusformat.org");
71 
72  jButton1.setText("OK");
73  jButton1.addActionListener(new java.awt.event.ActionListener() {
74  public void actionPerformed(java.awt.event.ActionEvent evt) {
75  jButton1ActionPerformed(evt);
76  }
77  });
78 
79  jScrollPane2.setViewportView(jEditorPane1);
80 
81  javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
82  jPanel1.setLayout(jPanel1Layout);
83  jPanel1Layout.setHorizontalGroup(
84  jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
85  .addGroup(jPanel1Layout.createSequentialGroup()
86  .addContainerGap()
87  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
88  .addGroup(jPanel1Layout.createSequentialGroup()
89  .addComponent(jLabel1)
90  .addGap(18, 18, 18)
91  .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 372, Short.MAX_VALUE)
92  .addContainerGap())
93  .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
94  .addComponent(jButton1)
95  .addGap(259, 259, 259))))
96  );
97  jPanel1Layout.setVerticalGroup(
98  jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
99  .addGroup(jPanel1Layout.createSequentialGroup()
100  .addContainerGap()
101  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
102  .addComponent(jLabel1)
103  .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 283, javax.swing.GroupLayout.PREFERRED_SIZE))
104  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 28, Short.MAX_VALUE)
105  .addComponent(jButton1)
106  .addContainerGap())
107  );
108 
109  javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
110  getContentPane().setLayout(layout);
111  layout.setHorizontalGroup(
112  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
113  .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
114  );
115  layout.setVerticalGroup(
116  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
117  .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
118  );
119 
120  pack();
121  }// </editor-fold>//GEN-END:initComponents
122 
123  private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
124  if (evt.getSource() == jButton1) {
125 
126  dispose();
127  }
128  }//GEN-LAST:event_jButton1ActionPerformed
129 
133  public static void main(String args[]) {
134  java.awt.EventQueue.invokeLater(new Runnable() {
135  public void run() {
136  AboutDialog dialog = new AboutDialog(new javax.swing.JFrame(), true);
137  dialog.addWindowListener(new java.awt.event.WindowAdapter() {
138  public void windowClosing(java.awt.event.WindowEvent e) {
139  System.exit(0);
140  }
141  });
142  dialog.setVisible(true);
143  }
144  });
145  }
146 
147  private void setup(){
148  try {
149  aboutHTMLStream =
150  AboutDialog.class.getResourceAsStream("resources/about.html");
151  aboutHTMLURL = AboutDialog.class.getResource("resources/about.html");
152  jEditorPane1.setEditable(false);
153  //jEditorPane1.read(aboutHTMLStream, null);
154  jEditorPane1.setPage(aboutHTMLURL);
155  //jEditorPane1.
156  } catch (IOException ex) {
157  Logger.getLogger(AboutDialog.class.getName()).log(Level.SEVERE,
158  "Failed to load about.html", ex);
159  }
160  }
161 
162  // Variables declaration - do not modify//GEN-BEGIN:variables
163  private javax.swing.JButton jButton1;
164  private javax.swing.JEditorPane jEditorPane1;
165  private javax.swing.JLabel jLabel1;
166  private javax.swing.JPanel jPanel1;
167  private javax.swing.JScrollPane jScrollPane2;
168  // End of variables declaration//GEN-END:variables
169 
170 }