NewApplication.java Source code

Java tutorial

Introduction

Here is the source code for NewApplication.java

Source

import java.io.FileInputStream;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Logger;
import java.util.logging.Level;
import java.util.logging.LogManager;
import javax.swing.DefaultListModel;
import javax.swing.JList;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableColumn;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/*
 * 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.
 */

/**
 *
 * @author admin
 */
public class NewApplication extends javax.swing.JFrame {

    private Log logger = LogFactory.getLog(NewApplication.class);

    /**
     * Creates new form NewApplication
     */
    public NewApplication() {
        initComponents();
        this.setTitle("Desktop J2EE Enterprise");
        initGUI();
        listEntities = jList1;

        logger.info("Test info");

        logger.debug("Test info");

        addWindowListener(new java.awt.event.WindowAdapter() {
            @Override
            public void windowClosing(java.awt.event.WindowEvent windowEvent) {

                System.out.println(logger.toString());

            }
        });

    }

    JList listEntities;

    DefaultTableModel tm = null;

    public void initGUI() {

        tm = new DefaultTableModel();

        tm.addColumn("ID");
        tm.addColumn("Account");

        jTable1.setModel(tm);

    }

    /**
     * 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() {

        jTextField2 = new javax.swing.JTextField();
        jSplitPane1 = new javax.swing.JSplitPane();
        jSplitPane2 = new javax.swing.JSplitPane();
        jPanel2 = new javax.swing.JPanel();
        jTextField3 = new javax.swing.JTextField();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel3 = new javax.swing.JPanel();
        jScrollPane3 = new javax.swing.JScrollPane();
        jTable2 = new javax.swing.JTable();
        jButton8 = new javax.swing.JButton();
        jPanel1 = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        jList1 = new javax.swing.JList();
        jToolBar1 = new javax.swing.JToolBar();
        jButton5 = new javax.swing.JButton();
        jButton6 = new javax.swing.JButton();
        jButton7 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        jButton4 = new javax.swing.JButton();
        menuBar = new javax.swing.JMenuBar();
        fileMenu = new javax.swing.JMenu();
        openMenuItem = new javax.swing.JMenuItem();
        saveMenuItem = new javax.swing.JMenuItem();
        saveAsMenuItem = new javax.swing.JMenuItem();
        exitMenuItem = new javax.swing.JMenuItem();
        editMenu = new javax.swing.JMenu();
        cutMenuItem = new javax.swing.JMenuItem();
        copyMenuItem = new javax.swing.JMenuItem();
        pasteMenuItem = new javax.swing.JMenuItem();
        deleteMenuItem = new javax.swing.JMenuItem();
        helpMenu = new javax.swing.JMenu();
        contentsMenuItem = new javax.swing.JMenuItem();
        aboutMenuItem = new javax.swing.JMenuItem();

        jTextField2.setText("jTextField2");

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jSplitPane1.setDividerLocation(300);
        jSplitPane1.setAutoscrolls(true);
        jSplitPane1.setMinimumSize(new java.awt.Dimension(179, 100));

        jSplitPane2.setDividerLocation(600);

        jTextField3.setText("30000000");

        jTable1.setModel(
                new javax.swing.table.DefaultTableModel(
                        new Object[][] { { null, null, null, null }, { null, null, null, null },
                                { null, null, null, null }, { null, null, null, null } },
                        new String[] { "Title 1", "Title 2", "Title 3", "Title 4" }));
        jTable1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jTable1MouseClicked(evt);
            }
        });
        jScrollPane1.setViewportView(jTable1);

        jButton1.setText("Get Entity");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jButton2.setText("Create New");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(jPanel2Layout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel2Layout.createSequentialGroup().addContainerGap().addGroup(jPanel2Layout
                        .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
                                jPanel2Layout.createSequentialGroup().addComponent(jButton1)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 140,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(18, 18, 18)
                                        .addComponent(jTextField3, javax.swing.GroupLayout.DEFAULT_SIZE, 322,
                                                Short.MAX_VALUE)
                                        .addGap(18, 18, 18))
                        .addGroup(jPanel2Layout
                                .createSequentialGroup().addComponent(jScrollPane1,
                                        javax.swing.GroupLayout.DEFAULT_SIZE, 535, Short.MAX_VALUE)
                                .addContainerGap()))));
        jPanel2Layout.setVerticalGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel2Layout.createSequentialGroup().addContainerGap()
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 396, Short.MAX_VALUE)
                        .addGap(8, 8, 8)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(jPanel2Layout
                                        .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                        .addComponent(jButton1).addComponent(jButton2))
                                .addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(21, 21, 21)));

        jSplitPane2.setLeftComponent(jPanel2);

        jTable2.setModel(
                new javax.swing.table.DefaultTableModel(
                        new Object[][] { { null, null, null, null }, { null, null, null, null },
                                { null, null, null, null }, { null, null, null, null } },
                        new String[] { "Title 1", "Title 2", "Title 3", "Title 4" }));
        jScrollPane3.setViewportView(jTable2);

        jButton8.setText("Update / insert");
        jButton8.setActionCommand("");
        jButton8.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton8ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout
                .setHorizontalGroup(
                        jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(jPanel3Layout.createSequentialGroup().addContainerGap()
                                        .addGroup(jPanel3Layout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        0, Short.MAX_VALUE)
                                                .addComponent(jButton8))
                                        .addContainerGap()));
        jPanel3Layout.setVerticalGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel3Layout.createSequentialGroup()
                        .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 384, Short.MAX_VALUE)
                        .addGap(18, 18, 18).addComponent(jButton8).addGap(6, 6, 6)));

        jTabbedPane1.addTab("Edit", jPanel3);

        jSplitPane2.setRightComponent(jTabbedPane1);

        jSplitPane1.setRightComponent(jSplitPane2);

        jList1.setModel(new javax.swing.AbstractListModel() {
            String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };

            public int getSize() {
                return strings.length;
            }

            public Object getElementAt(int i) {
                return strings[i];
            }
        });
        jList1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jList1MouseClicked(evt);
            }
        });
        jScrollPane2.setViewportView(jList1);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout
                .setHorizontalGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(jPanel1Layout.createSequentialGroup().addContainerGap().addComponent(jScrollPane2,
                                javax.swing.GroupLayout.DEFAULT_SIZE, 23, Short.MAX_VALUE)));
        jPanel1Layout.setVerticalGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel1Layout.createSequentialGroup().addContainerGap()
                        .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 439, Short.MAX_VALUE)
                        .addContainerGap()));

        jSplitPane1.setLeftComponent(jPanel1);

        jToolBar1.setRollover(true);

        jButton5.setText("Load");
        jButton5.setFocusable(false);
        jButton5.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton5.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jToolBar1.add(jButton5);

        jButton6.setText("Open");
        jButton6.setFocusable(false);
        jButton6.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton6.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jToolBar1.add(jButton6);

        jButton7.setText("Save");
        jButton7.setFocusable(false);
        jButton7.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton7.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jToolBar1.add(jButton7);

        jButton3.setText("All Entities");
        jButton3.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButton3MouseClicked(evt);
            }
        });

        jButton4.setText("Open");

        menuBar.setName("Desktop J2EE Enterprise"); // NOI18N

        fileMenu.setMnemonic('f');
        fileMenu.setText("File");

        openMenuItem.setMnemonic('o');
        openMenuItem.setText("Open");
        fileMenu.add(openMenuItem);

        saveMenuItem.setMnemonic('s');
        saveMenuItem.setText("Save");
        fileMenu.add(saveMenuItem);

        saveAsMenuItem.setMnemonic('a');
        saveAsMenuItem.setText("Save As ...");
        saveAsMenuItem.setDisplayedMnemonicIndex(5);
        fileMenu.add(saveAsMenuItem);

        exitMenuItem.setMnemonic('x');
        exitMenuItem.setText("Exit");
        exitMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                exitMenuItemActionPerformed(evt);
            }
        });
        fileMenu.add(exitMenuItem);

        menuBar.add(fileMenu);

        editMenu.setMnemonic('e');
        editMenu.setText("Edit");

        cutMenuItem.setMnemonic('t');
        cutMenuItem.setText("Cut");
        editMenu.add(cutMenuItem);

        copyMenuItem.setMnemonic('y');
        copyMenuItem.setText("Copy");
        editMenu.add(copyMenuItem);

        pasteMenuItem.setMnemonic('p');
        pasteMenuItem.setText("Paste");
        editMenu.add(pasteMenuItem);

        deleteMenuItem.setMnemonic('d');
        deleteMenuItem.setText("Delete");
        editMenu.add(deleteMenuItem);

        menuBar.add(editMenu);

        helpMenu.setMnemonic('h');
        helpMenu.setText("Help");

        contentsMenuItem.setMnemonic('c');
        contentsMenuItem.setText("Contents");
        helpMenu.add(contentsMenuItem);

        aboutMenuItem.setMnemonic('a');
        aboutMenuItem.setText("About");
        helpMenu.add(aboutMenuItem);

        menuBar.add(helpMenu);

        setJMenuBar(menuBar);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(jToolBar1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
                        Short.MAX_VALUE)
                .addGroup(layout.createSequentialGroup().addContainerGap()
                        .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 290,
                                javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                                javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 110,
                                javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap())
                .addComponent(jSplitPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 1117, Short.MAX_VALUE));
        layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                        .addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 25,
                                javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jSplitPane1, javax.swing.GroupLayout.DEFAULT_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jButton4)
                                .addGroup(layout.createSequentialGroup()
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jButton3)))
                        .addGap(15, 15, 15)));

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void exitMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exitMenuItemActionPerformed
        System.exit(0);
    }//GEN-LAST:event_exitMenuItemActionPerformed

    ArrayList<Class> ens = null;

    private void jButton3MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton3MouseClicked
        // TODO add your handling code here:

        try {
            ens = JavaApplication.GetEntities();
        } catch (Exception ex) {
        }
        ;

        DefaultListModel list = new DefaultListModel();

        for (Class ent : ens)
            list.addElement(ent.getName());

        listEntities.setModel(list);

    }//GEN-LAST:event_jButton3MouseClicked

    private void jList1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jList1MouseClicked
        // TODO add your handling code here:

        int index = listEntities.getSelectedIndex();

        if (index < 0)
            return;
        Class clazz = null;
        if (ens != null)
            clazz = (Class) ens.get(index);

        LoadTable(clazz);

    }//GEN-LAST:event_jList1MouseClicked

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        // TODO add your handling code here:

        if (clazz == null)
            return;

        EditTable(clazz);

        //new Thread(() -> doWork(someParam)).start();

        //try{
        //    JavaApplication.CreateAccount(jTextField3.getText());
        //}
        //catch(Exception ex){};
    }//GEN-LAST:event_jButton2ActionPerformed

    public Class clazz = null;

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // TODO add your handling code here:

        DefaultTableModel model = (DefaultTableModel) jTable1.getModel();

        model.setNumRows(0);

        jTable1.setModel(model);

        int index = listEntities.getSelectedIndex();

        if (index < 0)
            return;

        clazz = null;

        if (ens != null)
            clazz = (Class) ens.get(index);

        try {

            List<Object> acc = JavaApplication.GetEntities(clazz);

            int r = 0;

            int c = 0;

            for (Object a : acc) {

                Field[] fields = a.getClass().getDeclaredFields();

                Object[] obs = new Object[fields.length];

                model = (DefaultTableModel) jTable1.getModel();

                model.addRow(obs);

                jTable1.setModel(model);

                c = 0;

                for (Field field : fields) {

                    field.setAccessible(true);

                    Object v = field.get(a);

                    if (v == null)
                        v = "";

                    jTable1.getModel().setValueAt(v.toString(), r, c++);

                }

                r++;
            }

            jTable1.repaint();

            EditTable();

        } catch (Exception ex) {
        }
        ;
    }//GEN-LAST:event_jButton1ActionPerformed

    private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton8ActionPerformed
        // TODO add your handling code here:
        NewRecord();
    }//GEN-LAST:event_jButton8ActionPerformed

    private void jTable1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTable1MouseClicked
        // TODO add your handling code here:

        int index = jTable1.getSelectedRow();

        if (index < 0)
            return;

        Class clazz = null;

        if (JavaApplication.entities != null) {

            Object object = JavaApplication.entities.get(index);

            clazz = object.getClass();

            EditTable(clazz, object);

        }

    }//GEN-LAST:event_jTable1MouseClicked

    private void EditTable(Class clazz, Object object) {
        // TODO add your handling code here:

        DefaultTableModel model = (DefaultTableModel) jTable2.getModel();

        model.setColumnCount(3);

        model.setNumRows(0);

        jTable2.setModel(model);

        TableColumn tc = jTable2.getColumnModel().getColumn(0);
        tc.setHeaderValue("Field Name");
        tc = jTable2.getColumnModel().getColumn(1);
        tc.setHeaderValue("Value");
        tc = jTable2.getColumnModel().getColumn(2);
        tc.setHeaderValue("Type");

        try {

            Field[] fields = clazz.getDeclaredFields();

            for (Field f : fields) {

                Object[] obs = new Object[3];

                model = (DefaultTableModel) jTable2.getModel();

                f.setAccessible(true);

                obs[0] = f.getName();
                obs[1] = f.get(object);
                obs[2] = f.getType().getName();

                if (f.getName() == "" || f.getName() == null)
                    continue;

                model.addRow(obs);

                jTable2.setModel(model);

            }

            jTable2.repaint();

        } catch (Exception ex) {
        }
        ;
    }

    private void EditTable(Class clazz) {
        // TODO add your handling code here:

        DefaultTableModel model = (DefaultTableModel) jTable2.getModel();

        model.setColumnCount(3);

        model.setNumRows(0);

        jTable2.setModel(model);

        TableColumn tc = jTable2.getColumnModel().getColumn(0);
        tc.setHeaderValue("Field Name");
        tc = jTable2.getColumnModel().getColumn(1);
        tc.setHeaderValue("Value");
        tc = jTable2.getColumnModel().getColumn(2);
        tc.setHeaderValue("Type");

        try {

            Field[] fields = clazz.getDeclaredFields();

            for (Field f : fields) {

                Object[] obs = new Object[3];

                model = (DefaultTableModel) jTable2.getModel();

                f.setAccessible(true);

                obs[0] = f.getName();
                obs[2] = f.getType().getName();

                if (f.getName() == "" || f.getName() == null)
                    continue;

                model.addRow(obs);

                jTable2.setModel(model);

            }

            jTable2.repaint();

        } catch (Exception ex) {
        }
        ;
    }

    private void EditTable() {
        // TODO add your handling code here:

        DefaultTableModel model = (DefaultTableModel) jTable2.getModel();

        model.setColumnCount(3);

        model.setNumRows(0);

        jTable2.setModel(model);

        TableColumn tc = jTable2.getColumnModel().getColumn(0);
        tc.setHeaderValue("Field Name");
        tc = jTable2.getColumnModel().getColumn(1);
        tc.setHeaderValue("Value");
        tc = jTable2.getColumnModel().getColumn(2);
        tc.setHeaderValue("Type");

        int index = listEntities.getSelectedIndex();

        if (index < 0)
            return;
        Class clazz = null;
        if (ens != null)
            clazz = (Class) ens.get(index);

        try {

            Field[] fields = clazz.getDeclaredFields();

            for (Field f : fields) {

                Object[] obs = new Object[3];

                model = (DefaultTableModel) jTable2.getModel();

                f.setAccessible(true);

                obs[0] = f.getName();
                obs[2] = f.getType().getName();

                if (f.getName() == "" || f.getName() == null)
                    continue;

                model.addRow(obs);

                jTable2.setModel(model);

            }

            jTable2.repaint();

        } catch (Exception ex) {
        }
        ;
    }

    private void NewRecord() {
        // TODO add your handling code here:

        //int index = listEntities.getSelectedIndex();

        if (clazz == null)
            return;

        //  if(index < 0)
        //      return;
        //  Class clazz = null;
        //  if(ens != null)
        //      clazz = (Class)ens.get(index);

        Object obs = null;

        try {

            obs = clazz.newInstance();
        } catch (Exception ex) {
        }
        ;
        try {

            Field[] fields = clazz.getDeclaredFields();

            int i = 0;
            for (Field f : fields) {

                String value = (String) jTable2.getValueAt(i++, 1);

                if (value == null)
                    value = "";

                if (value == "")
                    continue;

                f.setAccessible(true);

                //obs[0] = f.getName();
                //obs[2] = f.getType().getName();

                if (f.getName() == "" || f.getName() == null)
                    continue;

                Object object = JavaApplication.toObject(f.getType(), value);

                if (object != null)
                    //if(object != "")

                    f.set(obs, object);

            }

            JavaApplication.CreateEntity(obs);

        } catch (Exception ex) {
        }
        ;

    }

    DefaultTableModel model = null;

    public void LoadTable(Class clazz) {

        model = new DefaultTableModel();

        Field[] fields = clazz.getDeclaredFields();

        Integer C = fields.length;

        model.setColumnCount(C);

        jTable1.setModel(model);

        for (int i = 0; i < C; i++) {

            TableColumn tc = jTable1.getColumnModel().getColumn(i);

            Field field = fields[i];

            tc.setHeaderValue(field.getName());

        }

        // Replace model

        jTable1.repaint();
    }

    /**
     * @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(NewApplication.class.getName()).log(java.util.logging.Level.SEVERE,
                    null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(NewApplication.class.getName()).log(java.util.logging.Level.SEVERE,
                    null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(NewApplication.class.getName()).log(java.util.logging.Level.SEVERE,
                    null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(NewApplication.class.getName()).log(java.util.logging.Level.SEVERE,
                    null, ex);
        }
        //</editor-fold>

        Logger log = Logger.getLogger("NewApplication");
        try {
            FileInputStream fis = new FileInputStream("p.properties");
            LogManager.getLogManager().readConfiguration(fis);
            log.setLevel(Level.FINE);
            log.addHandler(new java.util.logging.ConsoleHandler());
            log.setUseParentHandlers(false);

            log.info("starting NewApplication");
            fis.close();
        } catch (Exception e) {
        }
        ;

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new NewApplication().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenuItem aboutMenuItem;
    private javax.swing.JMenuItem contentsMenuItem;
    private javax.swing.JMenuItem copyMenuItem;
    private javax.swing.JMenuItem cutMenuItem;
    private javax.swing.JMenuItem deleteMenuItem;
    private javax.swing.JMenu editMenu;
    private javax.swing.JMenuItem exitMenuItem;
    private javax.swing.JMenu fileMenu;
    private javax.swing.JMenu helpMenu;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JButton jButton5;
    private javax.swing.JButton jButton6;
    private javax.swing.JButton jButton7;
    private javax.swing.JButton jButton8;
    private javax.swing.JList jList1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JSplitPane jSplitPane1;
    private javax.swing.JSplitPane jSplitPane2;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JTable jTable1;
    private javax.swing.JTable jTable2;
    private javax.swing.JTextField jTextField2;
    private javax.swing.JTextField jTextField3;
    private javax.swing.JToolBar jToolBar1;
    private javax.swing.JMenuBar menuBar;
    private javax.swing.JMenuItem openMenuItem;
    private javax.swing.JMenuItem pasteMenuItem;
    private javax.swing.JMenuItem saveAsMenuItem;
    private javax.swing.JMenuItem saveMenuItem;
    // End of variables declaration//GEN-END:variables

}