private void downloadDirectoryButtonActionPerformed(ActionEvent evt) {
   JFileChooser chooser = new JFileChooser();
   chooser.setCurrentDirectory(new File(Groovesquid.getConfig().getDownloadDirectory()));
   chooser.setDialogTitle(I18n.getLocaleString("SELECT_DOWNLOAD_DIRECTORY"));
   chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
   chooser.setAcceptAllFileFilterUsed(false);
   if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
     String downloadDirectory = chooser.getSelectedFile().getPath();
     Groovesquid.getConfig().setDownloadDirectory(downloadDirectory);
     downloadDirectoryTextField.setText(downloadDirectory);
   }
 }
  public void actionPerformed(ActionEvent e) {

    chooser = new JFileChooser();
    chooser.setCurrentDirectory(new File("C:\\Program Files (x86)\\Tango04\\Dashboards\\Web"));
    chooser.setDialogTitle("Browse...");
    chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    chooser.setAcceptAllFileFilterUsed(false);

    if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
      textArea.setText("");
      new Exportator().startExporting(chooser.getSelectedFile().getPath(), textArea);
    } else {
      textArea.setText("No Selection");
    }
  }
  /** Show the save dialog to save the network file. */
  private void saveEvent() {
    JFileChooser fileSaver = new JFileChooser(inpFile.getParent());
    fileSaver.setFileSelectionMode(JFileChooser.FILES_ONLY);
    fileSaver.setAcceptAllFileFilterUsed(false);
    fileSaver.addChoosableFileFilter(new XLSXFilter());
    fileSaver.addChoosableFileFilter(new XMLFilter());
    fileSaver.addChoosableFileFilter(new INPFilter());

    fileSaver.showSaveDialog(frame);

    if (fileSaver.getSelectedFile() == null) return;

    Network.FileType netType = Network.FileType.INP_FILE;

    if (fileSaver.getFileFilter() instanceof XLSXFilter) {
      netType = Network.FileType.EXCEL_FILE;
    } else if (fileSaver.getFileFilter() instanceof XMLFilter) {
      netType = Network.FileType.XML_FILE;
      JOptionPane.showMessageDialog(frame, "Not supported yet !", "Error", JOptionPane.OK_OPTION);
      return;
    }

    OutputComposer compose = OutputComposer.create(netType);

    String extension = "";

    if (Utilities.getFileExtension(fileSaver.getSelectedFile().getName()).equals(""))
      switch (netType) {
        case INP_FILE:
          extension = ".inp";
          break;
        case EXCEL_FILE:
          extension = ".xlsx";
          break;
        case XML_FILE:
          extension = ".xml";
          break;
      }

    try {
      compose.composer(
          epanetNetwork, new File(fileSaver.getSelectedFile().getAbsolutePath() + extension));
    } catch (ENException e1) {
      e1.printStackTrace();
    }
  }
Beispiel #4
0
 private void backup_folder_buttonActionPerformed(
     java.awt.event.ActionEvent evt) { // GEN-FIRST:event_backup_folder_buttonActionPerformed
   try {
     JFileChooser sel = new JFileChooser();
     sel.setCurrentDirectory(new java.io.File("."));
     sel.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
     sel.setAcceptAllFileFilterUsed(false);
     if (sel.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
       File selFile = sel.getSelectedFile();
       Backup_textfield.setText(selFile.getCanonicalPath());
       path_save_chat = selFile.getCanonicalPath() + "\\";
     } else {
       // do nothing
     }
   } catch (IOException ex) {
     Logger.getLogger(Options.class.getName()).log(Level.SEVERE, null, ex);
   }
 } // GEN-LAST:event_backup_folder_buttonActionPerformed
Beispiel #5
0
    @Override
    public void actionPerformed(ActionEvent e) {
      JFileChooser directoryChooser = new JFileChooser();
      directoryChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
      directoryChooser.setCurrentDirectory(new File(AbstractDownloader.directory));
      directoryChooser.setDialogTitle("Choose directory");

      // disable the "All files" option.
      directoryChooser.setAcceptAllFileFilterUsed(false);

      if (directoryChooser.showOpenDialog(directoryChooser) == JFileChooser.APPROVE_OPTION) {
        AbstractDownloader.directory = directoryChooser.getSelectedFile().getAbsolutePath() + "\\";

      } else {
        AbstractDownloader.directory = AbstractDownloader.DEFAULT_DIRECTORY;
      }
      // показываем обновленную надпись в label
      view.getPathTextField().setText(AbstractDownloader.directory);
    }
Beispiel #6
0
  private void Download_buttonActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_Download_buttonActionPerformed
    try {
      JFileChooser sel = new JFileChooser();

      sel.setCurrentDirectory(new java.io.File("."));
      sel.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);

      sel.setAcceptAllFileFilterUsed(false);
      if (sel.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
        File selFile = sel.getSelectedFile();
        Download_Textfield.setText(selFile.getCanonicalPath());
        path_save_download = selFile.getCanonicalPath();
      } else {
      }
    } catch (Exception ex) {

    }
  } // GEN-LAST:event_Download_buttonActionPerformed
  public static File startFileChooser(Component component, File selectedFile) {
    // Create a file chooser
    final JFileChooser fc = new JFileChooser();
    fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
    fc.setFileHidingEnabled(true);
    fc.setAcceptAllFileFilterUsed(false);
    if (selectedFile != null) fc.setSelectedFile(selectedFile);
    fc.setFileFilter(
        new FileFilter() {
          @Override
          public boolean accept(final File file) {
            if (file.isDirectory()) return true;
            String ext = Utils.getExtension(file);
            if (ext != null && ext.equals(Utils.XLS)) {
              return true;
            }
            return false;
          }

          @Override
          public String getDescription() {
            return "Excel *.xls";
          }
        });
    // In response to a button click:
    final int returnVal = fc.showOpenDialog(component);
    if (returnVal == JFileChooser.APPROVE_OPTION) {
      File file = fc.getSelectedFile();
      // This is where a real application would open the file.
      Log.d("Opening: " + file.getName() + ".");
      return file;
    } else {
      Log.d("Open command cancelled by user.");
    }
    return null;
  }
  /** Sets up dialog for saving instances in a file */
  public void setUpFile() {
    removeAll();

    m_fileChooser.setFileFilter(
        new FileFilter() {
          public boolean accept(File f) {
            return f.isDirectory();
          }

          public String getDescription() {
            return "Directory";
          }
        });

    m_fileChooser.setAcceptAllFileFilterUsed(false);

    try {
      if (!(((m_dsSaver.getSaver()).retrieveDir()).equals(""))) {
        String dirStr = m_dsSaver.getSaver().retrieveDir();
        if (Environment.containsEnvVariables(dirStr)) {
          try {
            dirStr = m_env.substitute(dirStr);
          } catch (Exception ex) {
            // ignore
          }
        }
        File tmp = new File(dirStr);
        tmp = new File(tmp.getAbsolutePath());
        m_fileChooser.setCurrentDirectory(tmp);
      }
    } catch (Exception ex) {
      System.out.println(ex);
    }

    JPanel innerPanel = new JPanel();
    innerPanel.setLayout(new BorderLayout());

    JPanel alignedP = new JPanel();
    GridBagLayout gbLayout = new GridBagLayout();
    alignedP.setLayout(gbLayout);

    JLabel prefixLab = new JLabel("Prefix for file name", SwingConstants.RIGHT);
    prefixLab.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0));
    GridBagConstraints gbConstraints = new GridBagConstraints();
    gbConstraints.anchor = GridBagConstraints.EAST;
    gbConstraints.fill = GridBagConstraints.HORIZONTAL;
    gbConstraints.gridy = 0;
    gbConstraints.gridx = 0;
    gbLayout.setConstraints(prefixLab, gbConstraints);
    alignedP.add(prefixLab);

    m_prefixText = new EnvironmentField();
    m_prefixText.setEnvironment(m_env);
    m_prefixText.setToolTipText(
        "Prefix for file name " + "(or filename itself if relation name is not used)");
    /*    int width = m_prefixText.getPreferredSize().width;
    int height = m_prefixText.getPreferredSize().height;
    m_prefixText.setMinimumSize(new Dimension(width * 2, height));
    m_prefixText.setPreferredSize(new Dimension(width * 2, height)); */
    gbConstraints = new GridBagConstraints();
    gbConstraints.anchor = GridBagConstraints.EAST;
    gbConstraints.fill = GridBagConstraints.HORIZONTAL;
    gbConstraints.gridy = 0;
    gbConstraints.gridx = 1;
    gbLayout.setConstraints(m_prefixText, gbConstraints);
    alignedP.add(m_prefixText);

    try {
      //      m_prefixText = new JTextField(m_dsSaver.getSaver().filePrefix(),25);

      m_prefixText.setText(m_dsSaver.getSaver().filePrefix());

      /*      final JLabel prefixLab =
      new JLabel(" Prefix for file name:", SwingConstants.LEFT); */

      JLabel relationLab = new JLabel("Relation name for filename", SwingConstants.RIGHT);
      relationLab.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0));
      gbConstraints = new GridBagConstraints();
      gbConstraints.anchor = GridBagConstraints.EAST;
      gbConstraints.fill = GridBagConstraints.HORIZONTAL;
      gbConstraints.gridy = 1;
      gbConstraints.gridx = 0;
      gbLayout.setConstraints(relationLab, gbConstraints);
      alignedP.add(relationLab);

      m_relationNameForFilename = new JCheckBox();
      m_relationNameForFilename.setSelected(m_dsSaver.getRelationNameForFilename());
      m_relationNameForFilename.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              if (m_relationNameForFilename.isSelected()) {
                m_prefixText.setLabel("Prefix for file name");
                m_fileChooser.setApproveButtonText("Select directory and prefix");
              } else {
                m_prefixText.setLabel("File name");
                m_fileChooser.setApproveButtonText("Select directory and filename");
              }
            }
          });

      gbConstraints = new GridBagConstraints();
      gbConstraints.anchor = GridBagConstraints.EAST;
      gbConstraints.fill = GridBagConstraints.HORIZONTAL;
      gbConstraints.gridy = 1;
      gbConstraints.gridx = 1;
      gbConstraints.weightx = 5;
      gbLayout.setConstraints(m_relationNameForFilename, gbConstraints);
      alignedP.add(m_relationNameForFilename);
    } catch (Exception ex) {
    }
    // innerPanel.add(m_SaverEditor, BorderLayout.SOUTH);
    JPanel about = m_SaverEditor.getAboutPanel();
    if (about != null) {
      innerPanel.add(about, BorderLayout.NORTH);
    }
    add(innerPanel, BorderLayout.NORTH);
    //    add(m_fileChooser, BorderLayout.CENTER);

    JLabel directoryLab = new JLabel("Directory", SwingConstants.RIGHT);
    directoryLab.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0));
    gbConstraints = new GridBagConstraints();
    gbConstraints.anchor = GridBagConstraints.EAST;
    gbConstraints.fill = GridBagConstraints.HORIZONTAL;
    gbConstraints.gridy = 2;
    gbConstraints.gridx = 0;
    gbLayout.setConstraints(directoryLab, gbConstraints);
    alignedP.add(directoryLab);

    m_directoryText = new EnvironmentField();
    //    m_directoryText.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    m_directoryText.setEnvironment(m_env);
    /*    width = m_directoryText.getPreferredSize().width;
    height = m_directoryText.getPreferredSize().height;
    m_directoryText.setMinimumSize(new Dimension(width * 2, height));
    m_directoryText.setPreferredSize(new Dimension(width * 2, height)); */

    try {
      m_directoryText.setText(m_dsSaver.getSaver().retrieveDir());
    } catch (IOException ex) {
      // ignore
    }

    JButton browseBut = new JButton("Browse...");
    browseBut.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            try {
              final JFrame jf = new JFrame("Choose directory");
              jf.getContentPane().setLayout(new BorderLayout());
              jf.getContentPane().add(m_fileChooser, BorderLayout.CENTER);
              jf.pack();
              jf.setVisible(true);
              m_fileChooserFrame = jf;
            } catch (Exception ex) {
              ex.printStackTrace();
            }
          }
        });

    JPanel efHolder = new JPanel();
    efHolder.setLayout(new BorderLayout());
    JPanel bP = new JPanel();
    bP.setLayout(new BorderLayout());
    bP.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 5));
    bP.add(browseBut, BorderLayout.CENTER);
    efHolder.add(m_directoryText, BorderLayout.CENTER);
    efHolder.add(bP, BorderLayout.EAST);
    // efHolder.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    gbConstraints = new GridBagConstraints();
    gbConstraints.anchor = GridBagConstraints.EAST;
    gbConstraints.fill = GridBagConstraints.HORIZONTAL;
    gbConstraints.gridy = 2;
    gbConstraints.gridx = 1;
    gbLayout.setConstraints(efHolder, gbConstraints);
    alignedP.add(efHolder);

    JLabel relativeLab = new JLabel("Use relative file paths", SwingConstants.RIGHT);
    relativeLab.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0));
    gbConstraints = new GridBagConstraints();
    gbConstraints.anchor = GridBagConstraints.EAST;
    gbConstraints.fill = GridBagConstraints.HORIZONTAL;
    gbConstraints.gridy = 3;
    gbConstraints.gridx = 0;
    gbLayout.setConstraints(relativeLab, gbConstraints);
    alignedP.add(relativeLab);

    m_relativeFilePath = new JCheckBox();
    m_relativeFilePath.setSelected(
        ((FileSourcedConverter) m_dsSaver.getSaver()).getUseRelativePath());

    m_relativeFilePath.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            ((FileSourcedConverter) m_dsSaver.getSaver())
                .setUseRelativePath(m_relativeFilePath.isSelected());
          }
        });
    gbConstraints = new GridBagConstraints();
    gbConstraints.anchor = GridBagConstraints.EAST;
    gbConstraints.fill = GridBagConstraints.HORIZONTAL;
    gbConstraints.gridy = 3;
    gbConstraints.gridx = 1;
    gbLayout.setConstraints(m_relativeFilePath, gbConstraints);
    alignedP.add(m_relativeFilePath);

    JButton OKBut = new JButton("OK");
    OKBut.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            try {
              (m_dsSaver.getSaver()).setFilePrefix(m_prefixText.getText());
              (m_dsSaver.getSaver()).setDir(m_directoryText.getText());
              m_dsSaver.setRelationNameForFilename(m_relationNameForFilename.isSelected());
            } catch (Exception ex) {
              ex.printStackTrace();
            }

            m_parentFrame.dispose();
          }
        });

    JButton CancelBut = new JButton("Cancel");
    CancelBut.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            m_parentFrame.dispose();
          }
        });

    JPanel butHolder = new JPanel();
    butHolder.setLayout(new FlowLayout());
    butHolder.add(OKBut);
    butHolder.add(CancelBut);
    JPanel holder2 = new JPanel();
    holder2.setLayout(new BorderLayout());
    holder2.add(alignedP, BorderLayout.NORTH);
    holder2.add(butHolder, BorderLayout.SOUTH);

    add(holder2, BorderLayout.SOUTH);
  }
  @Override
  public void actionPerformed(ActionEvent e) {
    if (e.getSource() == open) {
      if (isInProgress()) {
        systemIsBusy();
        return;
      }

      checkRunned();

      chooser = new JFileChooser();
      chooser.setAcceptAllFileFilterUsed(false);
      chooser.setFileFilter(new InputFileFilter(false));
      if (loadedFile != null) chooser.setSelectedFile(loadedFile);
      int returnValue = chooser.showOpenDialog(this);
      if (returnValue == JFileChooser.APPROVE_OPTION) {
        boolean approved =
            ((InputFileFilter) chooser.getFileFilter()).isFileApproved(chooser.getSelectedFile());
        if (approved) {
          startProgress();
          new MultiThread(
                  new Runnable() {
                    public void run() {
                      try {

                        loadedFile = chooser.getSelectedFile();
                        FileInputStream fis = new FileInputStream(loadedFile);
                        InputParser ip = new InputParser(fis);
                        if (ip.parseInput()) {
                          field = new Field(new ArrayList<Point>(Arrays.asList(ip.getPoints())));
                          minAlgo.setText(String.valueOf(ip.minimumClusters));
                          maxAlgo.setText(String.valueOf(ip.maximumClusters));
                        }
                      } catch (FileNotFoundException e1) {
                      }
                      contentpanel.center();
                      stopProgress();
                    }
                  })
              .start();
        }
      }
    } else if (e.getSource() == center) {
      if (isInProgress()) {
        systemIsBusy();
        return;
      }

      startProgress();
      new MultiThread(
              new Runnable() {
                public void run() {
                  contentpanel.removeMouseWheelListener(contentpanel);
                  contentpanel.center();
                  contentpanel.addMouseWheelListener(contentpanel);
                  stopProgressRepaint();
                }
              })
          .start();
    } else if (e.getSource() == save) {
      if (isInProgress()) {
        systemIsBusy();
        return;
      }

      checkRunned();

      chooser = new JFileChooser();
      chooser.setAcceptAllFileFilterUsed(false);
      chooser.setFileFilter(new InputFileFilter(true));
      if (loadedFile != null) chooser.setSelectedFile(loadedFile);
      int returnValue = chooser.showSaveDialog(this);
      if (returnValue == JFileChooser.APPROVE_OPTION) {
        boolean approved =
            ((InputFileFilter) chooser.getFileFilter()).isFileApproved(chooser.getSelectedFile());
        if (approved) {
          loadedFile = chooser.getSelectedFile();
          boolean halt = loadedFile.exists();
          if (halt) {
            int i =
                JOptionPane.showInternalConfirmDialog(
                    c,
                    "Are you sure you want to override this file?",
                    "Warning",
                    JOptionPane.YES_NO_OPTION,
                    JOptionPane.WARNING_MESSAGE);
            if (i == JOptionPane.YES_OPTION) {
              halt = false;
            }
          }

          if (!halt) {
            try {
              PrintWriter pw = new PrintWriter(new FileWriter(loadedFile));
              pw.println("find " + field.getNumberOfClusters() + " clusters");
              pw.println(field.size() + " points");
              Object[] obj = field.toArray();
              for (int i = 0; i < obj.length; i++) {
                Point p = (Point) obj[i];
                pw.println(p.getX() + " " + p.getY());
              }
              pw.close();
            } catch (IOException e1) {
            }
          }
        }
      }
    } else if (e.getSource() == clear) {
      if (isInProgress()) {
        systemIsBusy();
        return;
      }

      int i =
          JOptionPane.showInternalConfirmDialog(
              c,
              "Are you sure you want to clear the field?",
              "Warning",
              JOptionPane.YES_NO_OPTION,
              JOptionPane.WARNING_MESSAGE);

      checkRunned();
      if (i == JOptionPane.YES_OPTION) {
        field = new Field();
        updateContentPanel();
      }
    } else if (e.getSource() == circle) {
      contentpanel.setSelectionMode(ContentPanel.SELECT_CIRCLE);
    } else if (e.getSource() == square) {
      contentpanel.setSelectionMode(ContentPanel.SELECT_SQUARE);
    } else if (e.getSource() == addacluster) {
      if (isInProgress()) {
        systemIsBusy();
        return;
      }

      checkRunned();

      contentpanel.setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));
    } else if (e.getSource() == addnoise) {
      if (isInProgress()) {
        systemIsBusy();
        return;
      }

      checkRunned();
      final String s =
          JOptionPane.showInternalInputDialog(
              c, "How many points?", "Add noise", JOptionPane.QUESTION_MESSAGE);

      startProgress();
      new MultiThread(
              new Runnable() {
                public void run() {
                  if (s != null) {
                    int number;
                    try {
                      number = Integer.parseInt(s);
                    } catch (Exception ex) {
                      number = 0;
                    }

                    int tillX = 1000000000;
                    int tillY = 1000000000;
                    int addX = 0;
                    int addY = 0;
                    if (inRectangle.isSelected()) {
                      Rectangle r = field.getBoundingRectangle();
                      if (!(r.x1 == 0 && r.y1 == 0 && r.x2 == 0 && r.y2 == 0)) {
                        tillX = r.x2 - r.x1;
                        addX = r.x1;
                        tillY = r.y2 - r.y1;
                        addY = r.y1;
                      } else {
                        tillX = 500000000;
                        tillY = 500000000;
                      }
                    }

                    for (int i = 0; i < number; i++) {
                      int x = random.nextInt(tillX);
                      x += addX;
                      int y;

                      boolean busy = true;
                      while (busy) {
                        y = random.nextInt(tillY);
                        y += addY;
                        boolean inside = false;
                        Object[] array = field.toArray();
                        for (int j = 0; j < field.size(); j++) {
                          if (((Point) array[j]).compareTo(x, y)) {
                            inside = true;
                            break;
                          }
                        }

                        if (!inside) {
                          field.add(new Point(x, y));
                          busy = false;
                        }
                      }
                    }
                  }
                  stopProgress();
                }
              })
          .start();
    } else if (e.getSource() == run) {
      if (isInProgress()) {
        systemIsBusy();
        return;
      }

      checkRunned();

      startProgress();

      runAlgo();
    }
  }
Beispiel #10
0
  public void init() {

    areaventana = new JPanel();
    areabotones = new JPanel();
    imagen = new JLabel("");
    presentacion = new JButton(imgPlay);
    siguiente = new JButton(imgSiguiente);
    atras = new JButton(imgAnterior);
    ptiempo = new JSlider();
    carpeta = new JButton(imgNuevaCarpeta);
    grid = new JButton(imgGrid);
    bcomentario = new JButton(imgComentario);
    zoom = new JButton(imgZoom);

    /* Agregando los componentes */

    areaventana.add(imagen);
    // areaventana.add(desplazamiento);

    areabotones.add(grid);
    areabotones.add(atras);
    areabotones.add(presentacion);
    areabotones.add(siguiente);
    areabotones.add(ptiempo);
    areabotones.add(carpeta);
    areabotones.add(bcomentario);
    areabotones.add(zoom);

    areabotones.setBackground(colorGris);
    areaventana.setBackground(colorGris);

    // desplazamiento.setVisible(false);
    // areaventana.add(desplazamiento);

    /* GUI GUI GUI GUI  */
    presentacion.setBackground(colorGris);
    atras.setBackground(colorGris);
    siguiente.setBackground(colorGris);
    carpeta.setBackground(colorGris);
    grid.setBackground(colorGris);
    ptiempo.setBackground(colorGris);
    bcomentario.setBackground(colorGris);
    zoom.setBackground(colorGris);

    presentacion.setPreferredSize(new Dimension(100, 80));
    atras.setPreferredSize(new Dimension(100, 80));
    siguiente.setPreferredSize(new Dimension(100, 80));
    carpeta.setPreferredSize(new Dimension(100, 80));
    grid.setPreferredSize(new Dimension(100, 80));
    bcomentario.setPreferredSize(new Dimension(100, 80));
    zoom.setPreferredSize(new Dimension(100, 80));

    grid.setFocusPainted(false);
    atras.setFocusPainted(false);
    siguiente.setFocusPainted(false);
    carpeta.setFocusPainted(false);
    presentacion.setFocusPainted(false);
    bcomentario.setFocusPainted(false);
    zoom.setFocusPainted(false);

    grid.setBorder(null);
    atras.setBorder(null);
    siguiente.setBorder(null);
    carpeta.setBorder(null);
    presentacion.setBorder(null);
    areabotones.setBorder(null);
    areaventana.setBorder(null);
    bcomentario.setBorder(null);
    zoom.setBorder(null);
    /* GUI GUI GUI GUI  */

    /* Action Listeners */
    siguiente.addActionListener(this);
    atras.addActionListener(this);
    presentacion.addActionListener(this);
    carpeta.addActionListener(this);
    grid.addActionListener(this);
    bcomentario.addActionListener(this);
    zoom.addActionListener(this);

    this.setLayout(new BorderLayout());
    add(areaventana, BorderLayout.CENTER);
    add(areabotones, BorderLayout.SOUTH);

    ptiempo.setVisible(false);

    siguiente.setEnabled(false);
    atras.setEnabled(false);
    presentacion.setEnabled(false);
    grid.setEnabled(false);
    bcomentario.setEnabled(false);
    zoom.setEnabled(false);

    /* Abre el selector desde que inicia el programa */

    chooser = new JFileChooser();
    chooser.setDialogTitle("Selecciona una imagen...");
    chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
    chooser.setAcceptAllFileFilterUsed(false);

    // Abrir archivo es de acá...
    returnChooser = chooser.showOpenDialog(ArcViewer.this);

    if (returnChooser == 0) {

      imagenes = lista.Miranda(chooser, returnChooser);

      siguiente.setEnabled(true);
      atras.setEnabled(true);
      presentacion.setEnabled(true);
      grid.setEnabled(true);
      bcomentario.setEnabled(true);
      zoom.setEnabled(true);

      for (int asd1 = 0; asd1 < imagenes.size(); asd1++) {
        imagenesbean.add(new ImagenBean(imagenes.get(asd1), 0, 0));
      }

      String getImgSelected = chooser.getSelectedFile().getPath();

      for (int index = 0; index < imagenesbean.size(); index++) {
        if (getImgSelected.equals(imagenesbean.get(index).getIcon())) {
          imagen.setIcon(new ImageIcon(imagenesbean.get(index).getIcon()));
          indexaux = index;
        }
      }
    } else {
      System.out.println("No Selection");
      carpeta.setEnabled(true);
    }

    // for (int asd1=0; asd1 < imagenes.size(); asd1++) {
    // 	imagenesbean.add(new ImagenBean(imagenes.get(asd1),0,0));
    // }
    // String getImgSelected = chooser.getSelectedFile().getPath();
    // for (int index=0; index < imagenesbean.size(); index++) {
    // 	if (getImgSelected.equals( imagenesbean.get(index).getIcon() )) {
    // 		imagen.setIcon(new ImageIcon(imagenesbean.get(index).getIcon()));
    // 		indexaux = index;
    // 	}
    // }

  }
  /** Show the open dialog and open the INP/XLSX and XML files. */
  private void openEvent() {
    if (fileChooser == null) {
      // fileChooser = new FileDialog(frame);
      fileChooser = new JFileChooser(System.getProperty("user.dir"));
      fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
      fileChooser.setAcceptAllFileFilterUsed(false);
      fileChooser.addChoosableFileFilter(new XLSXFilter());
      fileChooser.addChoosableFileFilter(new XMLFilter());
      fileChooser.addChoosableFileFilter(new MSXFilter());
      fileChooser.addChoosableFileFilter(new INPFilter());
      fileChooser.addChoosableFileFilter(new AllSuportedFilesFilter());
    }

    if (fileChooser.showOpenDialog(frame) == JFileChooser.APPROVE_OPTION) {
      File netFile = fileChooser.getSelectedFile();
      String fileExtension = Utilities.getFileExtension(netFile.getName());

      if (fileExtension.equals("xlsx")
          || fileExtension.equals("inp")
          || fileExtension.equals("xml")) {
        inpFile = netFile;
        msxFile = null;
        msxName.setText("");

        Network.FileType netType = Network.FileType.INP_FILE;
        if (fileExtension.equals("xlsx")) netType = Network.FileType.EXCEL_FILE;
        else if (fileExtension.equals("xml")) {
          netType = Network.FileType.XML_FILE;
          JOptionPane.showMessageDialog(
              frame, "Not supported yet !", "Error", JOptionPane.OK_OPTION);
          return;
        }

        epanetNetwork = new Network();
        InputParser inpParser = InputParser.create(netType, log);
        try {
          inpParser.parse(epanetNetwork, inpFile);
        } catch (ENException en_ex) {
          JOptionPane.showMessageDialog(
              frame,
              en_ex.toString() + "\nCheck epanet.log for detailed error description",
              "Error",
              JOptionPane.OK_OPTION);
          clearInterface();
          inpFile = null;
          return;
        } catch (Exception egen) {
          JOptionPane.showMessageDialog(
              frame, "Unable to parse network configuration file", "Error", JOptionPane.OK_OPTION);
          log.log(ENLevels.ERROR, "openEvent", egen);
          clearInterface();
          inpFile = null;

          return;
        }

        int resrvCount = 0;
        int tanksCount = 0;

        for (Tank tank : epanetNetwork.getTanks())
          if (tank.getArea() == 0.0) resrvCount++;
          else tanksCount++;

        textReservoirs.setText(Integer.toString(resrvCount));
        textTanks.setText(Integer.toString(tanksCount));
        textPipes.setText(Integer.toString(epanetNetwork.getLinks().size()));
        textNodes.setText(Integer.toString(epanetNetwork.getNodes().size()));
        try {
          textDuration.setText(
              Utilities.getClockTime(epanetNetwork.getPropertiesMap().getDuration()));
          textUnits.setText(epanetNetwork.getPropertiesMap().getUnitsflag().name());
          textHeadloss.setText(epanetNetwork.getPropertiesMap().getFormflag().name());
          textQuality.setText(epanetNetwork.getPropertiesMap().getQualflag().name());
          textDemand.setText(epanetNetwork.getPropertiesMap().getDmult().toString());
          textHydraulic.setText(
              Utilities.getClockTime(epanetNetwork.getPropertiesMap().getHstep()));
          textPattern.setText(Utilities.getClockTime(epanetNetwork.getPropertiesMap().getPstep()));
        } catch (ENException ex) {
        }
        frame.setTitle(APP_TITTLE + inpFile.getName());
        inpName.setText(inpFile.getName());
        runSimulationButton.setEnabled(true);

        saveButton.setEnabled(true);
        reportOptions = null;
      } else if (fileExtension.equals("msx")) {
        if (inpFile == null) {
          JOptionPane.showMessageDialog(
              frame,
              "Load an INP or XLSX file with network configuration before opening the MSX file.",
              "Error",
              JOptionPane.OK_OPTION);
          return;
        }

        msxFile = netFile;
        msxName.setText(fileChooser.getSelectedFile().getName()); // fileChooser.getFile());
        reportOptions = null;
      }

      saveAction.setEnabled(true);
      runAction.setEnabled(true);
    }
  }