content: /*
   * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
   * Click nbfs://nbhost/SystemFileSystem/Templates/GUIForms/JFrame.java to edit this template
   */
  package com.eugc;
  
  import java.awt.Color;
  import java.awt.Cursor;
  import java.awt.Desktop;
  import java.awt.event.MouseAdapter;
  import java.awt.event.MouseEvent;
  import java.awt.event.MouseListener;
  import java.io.File;
  import java.io.IOException;
  import java.net.URI;
  import java.net.URISyntaxException;
  import javax.swing.JFileChooser;
  
  /**
   *
   * @author conor
   */
  public class DownloadComponent extends javax.swing.JFrame {
  
      /**
       * Creates new form DownloadComponent
       */
      public DownloadComponent() {
          initComponents();
      }
  
      /**
       * 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.
       */
      @SuppressWarnings("unchecked")
      // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
      private void initComponents() {
  
          Text1 = new javax.swing.JLabel();
          URL = new javax.swing.JLabel();
          Text2 = new javax.swing.JLabel();
          ImportZipBtn = new javax.swing.JButton();
          Cancel = new javax.swing.JButton();
  
          setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
  
          Text1.setText("jLabel1");
          Text1.setAutoscrolls(true);
          Text1.setFocusable(false);
  
          URL.setText("jLabel2");
  
          Text2.setText("jLabel3");
          Text2.setAutoscrolls(true);
  
          ImportZipBtn.setText("Import Zip");
          ImportZipBtn.addActionListener(new java.awt.event.ActionListener() {
              public void actionPerformed(java.awt.event.ActionEvent evt) {
                  ImportZipBtnActionPerformed(evt);
              }
          });
  
          Cancel.setText("Cancel");
          Cancel.addActionListener(new java.awt.event.ActionListener() {
              public void actionPerformed(java.awt.event.ActionEvent evt) {
                  CancelActionPerformed(evt);
              }
          });
  
          javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
          getContentPane().setLayout(layout);
          layout.setHorizontalGroup(
              layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
              .addGroup(layout.createSequentialGroup()
                  .addContainerGap()
                  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                      .addComponent(Text2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                      .addComponent(URL, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                      .addGroup(layout.createSequentialGroup()
                          .addComponent(Text1, javax.swing.GroupLayout.PREFERRED_SIZE, 939, javax.swing.GroupLayout.PREFERRED_SIZE)
                          .addContainerGap(14, Short.MAX_VALUE))))
              .addGroup(layout.createSequentialGroup()
                  .addGap(338, 338, 338)
                  .addComponent(ImportZipBtn)
                  .addGap(18, 18, 18)
                  .addComponent(Cancel)
                  .addGap(0, 0, Short.MAX_VALUE))
          );
          layout.setVerticalGroup(
              layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
              .addGroup(layout.createSequentialGroup()
                  .addContainerGap()
                  .addComponent(Text1, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE)
                  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                  .addComponent(URL, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
                  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                  .addComponent(Text2, javax.swing.GroupLayout.PREFERRED_SIZE, 78, javax.swing.GroupLayout.PREFERRED_SIZE)
                  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 40, Short.MAX_VALUE)
                  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                      .addComponent(ImportZipBtn)
                      .addComponent(Cancel))
                  .addContainerGap())
          );
  
          pack();
      }// </editor-fold>//GEN-END:initComponents
  
      private void ImportZipBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ImportZipBtnActionPerformed
          // TODO add your handling code here:
          if (evt.getSource() == ImportZipBtn) {
          int returnVal = fc.showOpenDialog(this);
  
          if (returnVal == JFileChooser.APPROVE_OPTION) {
              chosen = fc.getSelectedFile();
              this.setVisible(false);
          }
          }
      }//GEN-LAST:event_ImportZipBtnActionPerformed
  
      private void CancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CancelActionPerformed
          this.setVisible(false);
      }//GEN-LAST:event_CancelActionPerformed
  
      /**
       * @param args the command line arguments
       */
      public static void main(String args[]) {
          /* Set the Nimbus look and feel */
          //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
          /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
           * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
           */
          try {
              for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                  if ("Nimbus".equals(info.getName())) {
                      javax.swing.UIManager.setLookAndFeel(info.getClassName());
                      break;
                  }
              }
          } catch (ClassNotFoundException ex) {
              java.util.logging.Logger.getLogger(DownloadComponent.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
          } catch (InstantiationException ex) {
              java.util.logging.Logger.getLogger(DownloadComponent.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
          } catch (IllegalAccessException ex) {
              java.util.logging.Logger.getLogger(DownloadComponent.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
          } catch (javax.swing.UnsupportedLookAndFeelException ex) {
              java.util.logging.Logger.getLogger(DownloadComponent.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
          }
          //</editor-fold>
  
          /* Create and display the form */
          java.awt.EventQueue.invokeLater(new Runnable() {
              public void run() {
                  new DownloadComponent().setVisible(true);
              }
          });
      }
      
      public void updateDialog(String msg1, String msg2, String URLString){
          
          
          Text1.setText("<html><p> " + msg1.replace("\n", "</p><p>") + "</p></html>");
          Text2.setText(msg2);
          URL.setText(URLString);
          URL.setForeground(Color.BLUE.darker());
          URL.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
          for (MouseListener ml : URL.getMouseListeners()){
              URL.removeMouseListener(ml);
          }
          URL.addMouseListener(new MouseAdapter() {
              @Override
              public void mouseClicked(MouseEvent e) {
              try {
  
                  Desktop.getDesktop().browse(new URI(URLString));
  
              } catch (IOException | URISyntaxException e1) {
                  e1.printStackTrace();
              }
                      }
              @Override
              public void mouseEntered(MouseEvent e) {
              // the mouse has entered the label
              }
              @Override
              public void mouseExited(MouseEvent e) {
              // the mouse has exited the label
              }
   
          });
      }
  
      // Variables declaration - do not modify//GEN-BEGIN:variables
      private javax.swing.JButton Cancel;
      public javax.swing.JButton ImportZipBtn;
      private javax.swing.JLabel Text1;
      private javax.swing.JLabel Text2;
      private javax.swing.JLabel URL;
      // End of variables declaration//GEN-END:variables
      public File chosen;
      final JFileChooser fc = new JFileChooser();
  
  
  }
  