Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package UI; import core.Config; import java.io.File; import java.util.List; import javax.swing.JFileChooser; import javax.swing.JPanel; import org.apache.commons.io.FileUtils; public final class PDFrefVisualPanelFile extends JPanel { private Config mConfig = null; /** * Creates new form PDFrefVisualPanel1 */ public PDFrefVisualPanelFile() { initComponents(); } @Override public String getName() { return "Select Base Directory"; } /** * 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. */ // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { FileChooser = new javax.swing.JFileChooser(); jButton1 = new javax.swing.JButton(); jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); jScrollPane1 = new javax.swing.JScrollPane(); jTextArea1 = new javax.swing.JTextArea(); org.openide.awt.Mnemonics.setLocalizedText(jButton1, org.openide.util.NbBundle .getMessage(PDFrefVisualPanelFile.class, "PDFrefVisualPanelFile.jButton1.text")); // NOI18N jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } }); org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle .getMessage(PDFrefVisualPanelFile.class, "PDFrefVisualPanelFile.jLabel1.text")); // NOI18N jLabel2.setVisible(false); org.openide.awt.Mnemonics.setLocalizedText(jLabel2, org.openide.util.NbBundle .getMessage(PDFrefVisualPanelFile.class, "PDFrefVisualPanelFile.jLabel2.text")); // NOI18N jTextArea1.setColumns(20); jTextArea1.setRows(5); jScrollPane1.setViewportView(jTextArea1); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup().addGap(31, 31, 31).addGroup(layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 446, Short.MAX_VALUE) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel2).addComponent(jButton1).addComponent(jLabel1)) .addGap(0, 0, Short.MAX_VALUE))) .addContainerGap())); layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup().addGap(28, 28, 28).addComponent(jButton1) .addGap(18, 18, 18).addComponent(jLabel1).addGap(8, 8, 8).addComponent(jLabel2) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 338, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap())); }// </editor-fold>//GEN-END:initComponents private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed if (mConfig != null) { FileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); int returnVal = FileChooser.showOpenDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION) { File dir = FileChooser.getSelectedFile(); mConfig.setBaseFolder(dir); jLabel1.setText(mConfig.getBaseFolderString()); jLabel2.setText(Integer.toString(mConfig.getNbOfFiles()) + " files found"); jLabel2.setVisible(true); jTextArea1.setText(mConfig.getStringFilesList()); //jTextArea1.setVisible(true); } } }//GEN-LAST:event_jButton1ActionPerformed // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JFileChooser FileChooser; private javax.swing.JButton jButton1; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JTextArea jTextArea1; // End of variables declaration//GEN-END:variables /** * @return the mConfig */ public Config getConfig() { return mConfig; } /** * @param mConfig the mConfig to set */ public void setConfig(Config mConfig) { this.mConfig = mConfig; } }