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 epsi.i5.frame; import epsi.i5.datamining.Treatment; import epsi.i5.datamining.Weka; import epsi.i5.datamining.repustate.RepustateException; import java.io.IOException; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.filechooser.FileNameExtensionFilter; import org.json.simple.parser.ParseException; /** * * @author Edgar */ public class JFrame extends javax.swing.JFrame { /** * Creates new form JFrame */ public JFrame() { FileNameExtensionFilter filter = new FileNameExtensionFilter("JSON file", "json"); initComponents(); jFileChooser1.setFileFilter(filter); } /** * 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() { scrollPane1 = new java.awt.ScrollPane(); jDialog1 = new javax.swing.JDialog(); jFileChooser1 = new javax.swing.JFileChooser(); javax.swing.GroupLayout jDialog1Layout = new javax.swing.GroupLayout(jDialog1.getContentPane()); jDialog1.getContentPane().setLayout(jDialog1Layout); jDialog1Layout.setHorizontalGroup(jDialog1Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 400, Short.MAX_VALUE)); jDialog1Layout.setVerticalGroup(jDialog1Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 300, Short.MAX_VALUE)); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); jFileChooser1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jFileChooser1ActionPerformed(evt); } }); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jFileChooser1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)); layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent( jFileChooser1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)); pack(); }// </editor-fold>//GEN-END:initComponents private void jFileChooser1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jFileChooser1ActionPerformed if (evt.getActionCommand().equals("CancelSelection")) { setVisible(false); //you can't see me! dispose(); //Destroy the JFrame object } else { Treatment tr = new Treatment(); try { tr.treatment(jFileChooser1.getSelectedFile()); } catch (IOException | RepustateException | ParseException ex) { Logger.getLogger(JFrame.class.getName()).log(Level.SEVERE, null, ex); } Weka arff = new Weka(); try { arff.chargementData(tr.dataEnter); arff.generationArff(); arff.generationArffFilter(); arff.excutionAlgo(); } catch (Exception ex) { Logger.getLogger(JFrame.class.getName()).log(Level.SEVERE, null, ex); } } }//GEN-LAST:event_jFileChooser1ActionPerformed /** * @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 | InstantiationException | IllegalAccessException | javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(JFrame.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 JFrame().setVisible(true); } }); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JDialog jDialog1; private javax.swing.JFileChooser jFileChooser1; private java.awt.ScrollPane scrollPane1; // End of variables declaration//GEN-END:variables }