package miw2; import jpl.Compound; /** * Class shows informations with button OK only. * @author Filip */ public class Info extends javax.swing.JFrame { /** * State if Form should be visible. */ private boolean enable = true; /** * Create form with given informations as String list. * @param str informations. */ public Info(String[] str) { initComponents(); String question = ""; for (String s : str) { question += s + "\n"; } jTextArea1.setText(question); this.setTitle("Info"); this.setLocationRelativeTo(null); this.setResizable(false); this.setDefaultCloseOperation(Info.DO_NOTHING_ON_CLOSE); this.setVisible(true); try { while (enable) { Thread.sleep(100); } } catch (Exception ex) { ex.printStackTrace(); } } /** * Create form with given informations as Compound list. * @param str informations. */ public Info(Compound[] str) { initComponents(); String question = ""; for (Compound s : str) { question += s.toString() + "\n"; } jTextArea1.setText(question); this.setTitle("Info"); this.setLocationRelativeTo(null); this.setResizable(false); this.setDefaultCloseOperation(Info.DO_NOTHING_ON_CLOSE); this.setVisible(true); try { while (enable) { Thread.sleep(100); } } catch (Exception ex) { ex.printStackTrace(); } } /** * Create form with given informations as String. * @param str informations. */ public Info(String str) { initComponents(); String question = str; jTextArea1.setText(question); this.setTitle("Info"); this.setLocationRelativeTo(null); this.setResizable(false); this.setDefaultCloseOperation(Info.DO_NOTHING_ON_CLOSE); this.setVisible(true); try { while (enable) { Thread.sleep(100); } } catch (Exception ex) { ex.printStackTrace(); } } /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ // private void initComponents() { jScrollPane1 = new javax.swing.JScrollPane(); jTextArea1 = new javax.swing.JTextArea(); jButton1 = new javax.swing.JButton(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); jTextArea1.setBackground(new java.awt.Color(224, 223, 227)); jTextArea1.setColumns(20); jTextArea1.setEditable(false); jTextArea1.setRows(5); jTextArea1.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1)); jTextArea1.setOpaque(false); jTextArea1.setSelectionColor(new java.awt.Color(224, 223, 227)); jScrollPane1.setViewportView(jTextArea1); jButton1.setText("OK"); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } }); org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(layout.createSequentialGroup() .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(layout.createSequentialGroup() .add(149, 149, 149) .add(jButton1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 89, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 137, Short.MAX_VALUE)) .add(layout.createSequentialGroup() .add(20, 20, 20) .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 355, Short.MAX_VALUE))) .add(30, 30, 30)) ); layout.setVerticalGroup( layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup() .addContainerGap() .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 264, Short.MAX_VALUE) .add(18, 18, 18) .add(jButton1) .add(21, 21, 21)) ); pack(); }// private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: enable = false; this.dispose(); } /** * @param args the command line arguments */ public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new Info(new String[]{"one ", "two"}); } }); } // Variables declaration - do not modify private javax.swing.JButton jButton1; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JTextArea jTextArea1; // End of variables declaration }