Guest User

GUI

a guest
Jul 30th, 2013
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 12.64 KB | None | 0 0
  1.  
  2. import java.io.File;
  3. import javax.swing.JFileChooser;
  4.  
  5. /*
  6.  * To change this template, choose Tools | Templates
  7.  * and open the template in the editor.
  8.  */
  9.  
  10. /**
  11.  *
  12.  * @author dmallory
  13.  */
  14. public class GenomeGUI extends javax.swing.JFrame {
  15.  
  16.     /**
  17.      * Creates new form GenomeGUI
  18.      */
  19.     public GenomeGUI() {
  20.         initComponents();
  21.     }
  22.  
  23.     /**
  24.      * This method is called from within the constructor to initialize the form.
  25.      * WARNING: Do NOT modify this code. The content of this method is always
  26.      * regenerated by the Form Editor.
  27.      */
  28.     @SuppressWarnings("unchecked")
  29.     // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
  30.     private void initComponents() {
  31.  
  32.         jInternalFrame1 = new javax.swing.JInternalFrame();
  33.         jLabel3 = new javax.swing.JLabel();
  34.         jTextField1 = new javax.swing.JTextField();
  35.         jButton1 = new javax.swing.JButton();
  36.         jComboBox1 = new javax.swing.JComboBox();
  37.         jLabel1 = new javax.swing.JLabel();
  38.         jLabel4 = new javax.swing.JLabel();
  39.         jTextField2 = new javax.swing.JTextField();
  40.         jButton2 = new javax.swing.JButton();
  41.         jButton3 = new javax.swing.JButton();
  42.         jScrollPane1 = new javax.swing.JScrollPane();
  43.         jTextPane1 = new javax.swing.JTextPane();
  44.  
  45.         setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
  46.  
  47.         jInternalFrame1.setVisible(true);
  48.  
  49.         jLabel3.setFont(new java.awt.Font("Times New Roman", 0, 18)); // NOI18N
  50.         jLabel3.setForeground(new java.awt.Color(255, 0, 0));
  51.         jLabel3.setText("1. Choose Genome File");
  52.  
  53.         jTextField1.addActionListener(new java.awt.event.ActionListener() {
  54.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  55.                 jTextField1ActionPerformed(evt);
  56.             }
  57.         });
  58.  
  59.         jButton1.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
  60.         jButton1.setForeground(new java.awt.Color(0, 0, 204));
  61.         jButton1.setText("Browse");
  62.         jButton1.addActionListener(new java.awt.event.ActionListener() {
  63.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  64.                 jButton1ActionPerformed(evt);
  65.             }
  66.         });
  67.  
  68.         jComboBox1.setFont(new java.awt.Font("Times New Roman", 0, 18)); // NOI18N
  69.         jComboBox1.setForeground(new java.awt.Color(0, 51, 255));
  70.         jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
  71.  
  72.         jLabel1.setFont(new java.awt.Font("Times New Roman", 0, 18)); // NOI18N
  73.         jLabel1.setForeground(new java.awt.Color(255, 0, 0));
  74.         jLabel1.setText("2. Choose Motif");
  75.  
  76.         jLabel4.setFont(new java.awt.Font("Times New Roman", 0, 18)); // NOI18N
  77.         jLabel4.setForeground(new java.awt.Color(255, 0, 0));
  78.         jLabel4.setText("3. Choose Output File");
  79.  
  80.         jButton2.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
  81.         jButton2.setForeground(new java.awt.Color(0, 0, 255));
  82.         jButton2.setText("Browse");
  83.         jButton2.addActionListener(new java.awt.event.ActionListener() {
  84.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  85.                 jButton2ActionPerformed(evt);
  86.             }
  87.         });
  88.  
  89.         jButton3.setFont(new java.awt.Font("Times New Roman", 0, 24)); // NOI18N
  90.         jButton3.setForeground(new java.awt.Color(0, 0, 255));
  91.         jButton3.setText("Run Program");
  92.         jButton3.addActionListener(new java.awt.event.ActionListener() {
  93.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  94.                 jButton3ActionPerformed(evt);
  95.             }
  96.         });
  97.  
  98.         jTextPane1.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
  99.         jTextPane1.setForeground(new java.awt.Color(0, 0, 255));
  100.         jTextPane1.setText("But the Republican idealism hasn't been working for you, has it?\n\n\"It could!\"\n\n-Random Mississipian Redneck");
  101.         jScrollPane1.setViewportView(jTextPane1);
  102.  
  103.         org.jdesktop.layout.GroupLayout jInternalFrame1Layout = new org.jdesktop.layout.GroupLayout(jInternalFrame1.getContentPane());
  104.         jInternalFrame1.getContentPane().setLayout(jInternalFrame1Layout);
  105.         jInternalFrame1Layout.setHorizontalGroup(
  106.             jInternalFrame1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
  107.             .add(jInternalFrame1Layout.createSequentialGroup()
  108.                 .add(186, 186, 186)
  109.                 .add(jButton2)
  110.                 .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
  111.             .add(jInternalFrame1Layout.createSequentialGroup()
  112.                 .add(27, 27, 27)
  113.                 .add(jInternalFrame1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
  114.                     .add(jTextField2)
  115.                     .add(jInternalFrame1Layout.createSequentialGroup()
  116.                         .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 211, Short.MAX_VALUE)
  117.                         .add(276, 276, 276))
  118.                     .add(jTextField1)
  119.                     .add(jInternalFrame1Layout.createSequentialGroup()
  120.                         .add(jInternalFrame1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
  121.                             .add(jButton3)
  122.                             .add(jInternalFrame1Layout.createSequentialGroup()
  123.                                 .add(jLabel1)
  124.                                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
  125.                                 .add(jComboBox1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
  126.                             .add(jInternalFrame1Layout.createSequentialGroup()
  127.                                 .add(jLabel3)
  128.                                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
  129.                                 .add(jButton1))
  130.                             .add(jLabel4))
  131.                         .add(0, 0, Short.MAX_VALUE)))
  132.                 .addContainerGap())
  133.         );
  134.         jInternalFrame1Layout.setVerticalGroup(
  135.             jInternalFrame1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
  136.             .add(org.jdesktop.layout.GroupLayout.TRAILING, jInternalFrame1Layout.createSequentialGroup()
  137.                 .add(22, 22, 22)
  138.                 .add(jInternalFrame1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
  139.                     .add(jLabel3)
  140.                     .add(jButton1))
  141.                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
  142.                 .add(jTextField1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 29, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
  143.                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
  144.                 .add(jInternalFrame1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
  145.                     .add(jLabel1)
  146.                     .add(jComboBox1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
  147.                 .add(10, 10, 10)
  148.                 .add(jInternalFrame1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
  149.                     .add(jLabel4)
  150.                     .add(jButton2))
  151.                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
  152.                 .add(jTextField2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
  153.                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
  154.                 .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 108, Short.MAX_VALUE)
  155.                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
  156.                 .add(jButton3)
  157.                 .add(34, 34, 34))
  158.         );
  159.  
  160.         org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
  161.         getContentPane().setLayout(layout);
  162.         layout.setHorizontalGroup(
  163.             layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
  164.             .add(jInternalFrame1)
  165.         );
  166.         layout.setVerticalGroup(
  167.             layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
  168.             .add(layout.createSequentialGroup()
  169.                 .add(jInternalFrame1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
  170.                 .add(0, 0, Short.MAX_VALUE))
  171.         );
  172.  
  173.         pack();
  174.     }// </editor-fold>                        
  175.  
  176.     private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                        
  177.             JFileChooser chooser = new JFileChooser();
  178.             int returnVal = chooser.showOpenDialog(this);
  179.             if(returnVal == JFileChooser.APPROVE_OPTION)
  180.             {
  181.                 File selectedFile = chooser.getSelectedFile();
  182.                 String fileName = selectedFile.getAbsolutePath();
  183.                 jTextField1.setText(fileName);
  184.             }
  185.     }                                        
  186.  
  187.     private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {                                            
  188.         // TODO add your handling code here:
  189.     }                                          
  190.  
  191.     private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {                                        
  192.           JFileChooser chooser = new JFileChooser();
  193.             int returnVal = chooser.showOpenDialog(this);
  194.             if(returnVal == JFileChooser.APPROVE_OPTION)
  195.             {
  196.                 File selectedFile = chooser.getSelectedFile();
  197.                 String fileName = selectedFile.getAbsolutePath();
  198.                 jTextField2.setText(fileName);
  199.             }
  200.     }                                        
  201.  
  202.     private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {                                        
  203.         // TODO add your handling code here:
  204.     }                                        
  205.  
  206.     /**
  207.      * @param args the command line arguments
  208.      */
  209.     public static void main(String args[]) {
  210.         /* Set the Nimbus look and feel */
  211.         //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
  212.         /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
  213.          * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
  214.          */
  215.         try {
  216.             for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
  217.                 if ("Nimbus".equals(info.getName())) {
  218.                     javax.swing.UIManager.setLookAndFeel(info.getClassName());
  219.                     break;
  220.                 }
  221.             }
  222.         } catch (ClassNotFoundException ex) {
  223.             java.util.logging.Logger.getLogger(GenomeGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  224.         } catch (InstantiationException ex) {
  225.             java.util.logging.Logger.getLogger(GenomeGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  226.         } catch (IllegalAccessException ex) {
  227.             java.util.logging.Logger.getLogger(GenomeGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  228.         } catch (javax.swing.UnsupportedLookAndFeelException ex) {
  229.             java.util.logging.Logger.getLogger(GenomeGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  230.         }
  231.         //</editor-fold>
  232.  
  233.         /* Create and display the form */
  234.         java.awt.EventQueue.invokeLater(new Runnable() {
  235.             public void run() {
  236.                 new GenomeGUI().setVisible(true);
  237.             }
  238.         });
  239.     }
  240.     // Variables declaration - do not modify                    
  241.     private javax.swing.JButton jButton1;
  242.     private javax.swing.JButton jButton2;
  243.     private javax.swing.JButton jButton3;
  244.     private javax.swing.JComboBox jComboBox1;
  245.     private javax.swing.JInternalFrame jInternalFrame1;
  246.     private javax.swing.JLabel jLabel1;
  247.     private javax.swing.JLabel jLabel3;
  248.     private javax.swing.JLabel jLabel4;
  249.     private javax.swing.JScrollPane jScrollPane1;
  250.     private javax.swing.JTextField jTextField1;
  251.     private javax.swing.JTextField jTextField2;
  252.     private javax.swing.JTextPane jTextPane1;
  253.     // End of variables declaration                  
  254. }
Advertisement
Add Comment
Please, Sign In to add comment