View Javadoc
1 /* 2 * SolarHazardDialog.java 3 * 4 * Copyright (c) 2003, Raben Systems, Inc. 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions are met: 9 * 10 * Redistributions of source code must retain the above copyright notice, 11 * this list of conditions and the following disclaimer. 12 * 13 * Redistributions in binary form must reproduce the above copyright notice, 14 * this list of conditions and the following disclaimer in the documentation 15 * and/or other materials provided with the distribution. 16 * 17 * Neither the name of Raben Systems, Inc. nor the names of its contributors 18 * may be used to endorse or promote products derived from this software 19 * without specific prior written permission. 20 * 21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 25 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 * POSSIBILITY OF SUCH DAMAGE. 32 */ 33 34 package com.raben.telescope.comm; 35 import java.util.ResourceBundle; 36 37 /*** 38 * Dialog to display solar hazard warning 39 * @author Vern Raben 40 */ 41 public class SolarHazardDialog extends javax.swing.JDialog { 42 43 /*** Creates new form SolarHazardDialog 44 * @param parent Reference to Frame parent 45 * @param modal True if dialog to be displayed modal 46 */ 47 public SolarHazardDialog(java.awt.Frame parent, boolean modal) { 48 super(parent, modal); 49 initComponents(); 50 } 51 52 /*** This method is called from within the constructor to 53 * initialize the form. 54 * WARNING: Do NOT modify this code. The content of this method is 55 * always regenerated by the Form Editor. 56 */ 57 private void initComponents() {//GEN-BEGIN:initComponents 58 jScrollPane1 = new javax.swing.JScrollPane(); 59 warningTextArea = new javax.swing.JTextArea(); 60 jPanel2 = new javax.swing.JPanel(); 61 declineButton = new javax.swing.JButton(); 62 acceptButton = new javax.swing.JButton(); 63 64 getContentPane().setLayout(new javax.swing.BoxLayout(getContentPane(), javax.swing.BoxLayout.Y_AXIS)); 65 66 setTitle(java.util.ResourceBundle.getBundle("resources/comm/Telescope").getString("SOLAR_HAZARD_WARNING_TITLE")); 67 addWindowListener(new java.awt.event.WindowAdapter() { 68 public void windowClosing(java.awt.event.WindowEvent evt) { 69 closeDialog(evt); 70 } 71 }); 72 73 warningTextArea.setColumns(55); 74 warningTextArea.setEditable(false); 75 warningTextArea.setLineWrap(true); 76 warningTextArea.setRows(15); 77 warningTextArea.setText(getWarning()); 78 jScrollPane1.setViewportView(warningTextArea); 79 80 getContentPane().add(jScrollPane1); 81 82 jPanel2.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT)); 83 84 declineButton.setMnemonic('D'); 85 declineButton.setText(java.util.ResourceBundle.getBundle("resources/comm/Telescope").getString("IGNORE")); 86 declineButton.addActionListener(new java.awt.event.ActionListener() { 87 public void actionPerformed(java.awt.event.ActionEvent evt) { 88 declineButtonActionPerformed(evt); 89 } 90 }); 91 92 jPanel2.add(declineButton); 93 94 acceptButton.setMnemonic('A'); 95 acceptButton.setText(java.util.ResourceBundle.getBundle("resources/comm/Telescope").getString("ACKNOWLEDGE")); 96 acceptButton.addActionListener(new java.awt.event.ActionListener() { 97 public void actionPerformed(java.awt.event.ActionEvent evt) { 98 acceptButtonActionPerformed(evt); 99 } 100 }); 101 102 jPanel2.add(acceptButton); 103 104 getContentPane().add(jPanel2); 105 106 pack(); 107 }//GEN-END:initComponents 108 109 private void declineButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_declineButtonActionPerformed 110 accepted = false; 111 closeDialog(null); 112 }//GEN-LAST:event_declineButtonActionPerformed 113 114 private void acceptButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_acceptButtonActionPerformed 115 accepted = true; 116 closeDialog(null); 117 }//GEN-LAST:event_acceptButtonActionPerformed 118 119 /*** Closes the dialog */ 120 private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog 121 firePropertyChange(ACCEPT_RESPONSE, null, String.valueOf(accepted)); 122 setVisible(false); 123 dispose(); 124 }//GEN-LAST:event_closeDialog 125 126 /*** 127 * @param args the command line arguments 128 */ 129 public static void main(String args[]) { 130 SolarHazardDialog solarHazardDialog 131 = new SolarHazardDialog(new javax.swing.JFrame(), true); 132 solarHazardDialog.setStandalone(true); 133 solarHazardDialog.show(); 134 } 135 /*** 136 * Get hazard warning from resource bundle 137 * @return The solar hazard warning in a String 138 */ 139 public String getWarning() { 140 return ResourceBundle.getBundle("resources/comm/Telescope").getString("SOLAR_HAZARD_WARNING_TEXT"); 141 } 142 143 /*** 144 * Return true if hazard warning is acknowledged 145 * @return True if accepted 146 */ 147 public boolean isAccepted() { 148 return accepted; 149 } 150 151 /*** Getter for property standalone. 152 * @return Value of property standalone. 153 */ 154 public boolean isStandalone() { 155 return this.standalone; 156 } 157 158 /*** Setter for property standalone. 159 * @param standalone New value of property standalone. 160 */ 161 public void setStandalone(boolean standalone) { 162 this.standalone = standalone; 163 } 164 165 // Variables declaration - do not modify//GEN-BEGIN:variables 166 private javax.swing.JPanel jPanel2; 167 private javax.swing.JScrollPane jScrollPane1; 168 private javax.swing.JButton acceptButton; 169 private javax.swing.JTextArea warningTextArea; 170 private javax.swing.JButton declineButton; 171 // End of variables declaration//GEN-END:variables 172 173 /*** Flag to indicate if solar hazard warning is acknowledged */ 174 private boolean accepted = false; 175 176 /*** Define message to property listener */ 177 public static final String ACCEPT_RESPONSE = "accepted"; 178 179 /*** Holds value of property standalone. */ 180 private boolean standalone; 181 182 }

This page was automatically generated by Maven