statisticsintegration.StatisticsLabr.java Source code

Java tutorial

Introduction

Here is the source code for statisticsintegration.StatisticsLabr.java

Source

/*
 * 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 statisticsintegration;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableColumn;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartFrame;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.plot.PiePlot3D;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.data.category.DefaultCategoryDataset;
import org.jfree.data.general.DefaultPieDataset;

/**
 *
 * @author Danielle98
 */
public class StatisticsLabr extends javax.swing.JFrame {

    /**
     * Creates new form StatisticsLabr
     */
    public StatisticsLabr() {
        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() {

        Warnings = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();
        jButton1 = new javax.swing.JButton();
        Desc2 = new javax.swing.JLabel();
        Warnings1 = new javax.swing.JTextField();
        jScrollPane2 = new javax.swing.JScrollPane();
        total = new javax.swing.JTextPane();
        jButton2 = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        Categorical = new javax.swing.JRadioButton();
        Numerical = new javax.swing.JRadioButton();
        Desc = new javax.swing.JTextField();
        ok1 = new javax.swing.JButton();
        Size = new javax.swing.JTextField();
        ok2 = new javax.swing.JButton();
        Chart = new javax.swing.JCheckBox();
        jLabel3 = new javax.swing.JLabel();
        collapse = new javax.swing.JCheckBox();
        choice = new javax.swing.JComboBox<>();
        back = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jLabel4.setText("Size:");

        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[] { "-", "-", "-", "-" }));
        jScrollPane1.setViewportView(jTable1);

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

        Warnings1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Warnings1ActionPerformed(evt);
            }
        });

        jScrollPane2.setViewportView(total);

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

        jLabel1.setText("Summarizing and Presenting Data");

        Categorical.setText("Categorical");
        Categorical.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                CategoricalActionPerformed(evt);
            }
        });

        Numerical.setText("Numerical");

        ok1.setText("OK");
        ok1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ok1ActionPerformed(evt);
            }
        });

        Size.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                SizeActionPerformed(evt);
            }
        });

        ok2.setText("OK");
        ok2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ok2ActionPerformed(evt);
            }
        });

        Chart.setText("CHART");

        jLabel3.setText("Description:");

        collapse.setText("COLLAPSE");

        choice.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Integer", "Floating" }));

        back.setText("Back");
        back.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                backActionPerformed(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().addGroup(layout
                        .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(layout.createSequentialGroup().addGap(24, 24, 24).addGroup(layout
                                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(layout.createSequentialGroup().addGroup(layout
                                        .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(Categorical)
                                        .addGroup(layout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,
                                                        false)
                                                .addComponent(ok2, javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                .addComponent(Size, javax.swing.GroupLayout.PREFERRED_SIZE, 47,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addComponent(jLabel4).addComponent(Numerical).addComponent(collapse)
                                        .addComponent(Chart)).addGap(18, 18, 18)
                                        .addGroup(layout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                .addComponent(Desc2, javax.swing.GroupLayout.PREFERRED_SIZE, 172,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addGroup(layout
                                                        .createParallelGroup(
                                                                javax.swing.GroupLayout.Alignment.TRAILING, false)
                                                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout
                                                                .createSequentialGroup()
                                                                .addComponent(jScrollPane2,
                                                                        javax.swing.GroupLayout.PREFERRED_SIZE, 146,
                                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                                .addGap(111, 111, 111)
                                                                .addComponent(jButton2,
                                                                        javax.swing.GroupLayout.PREFERRED_SIZE, 76,
                                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                                .addPreferredGap(
                                                                        javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                        Short.MAX_VALUE)
                                                                .addComponent(jButton1))
                                                        .addComponent(jScrollPane1,
                                                                javax.swing.GroupLayout.Alignment.LEADING,
                                                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                javax.swing.GroupLayout.PREFERRED_SIZE))))
                                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                        .addComponent(jLabel3)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(Desc, javax.swing.GroupLayout.PREFERRED_SIZE, 251,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(ok1, javax.swing.GroupLayout.PREFERRED_SIZE, 62,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(choice, javax.swing.GroupLayout.PREFERRED_SIZE, 91,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(42, 42, 42))))
                        .addGroup(layout.createSequentialGroup().addGap(87, 87, 87).addComponent(Warnings1,
                                javax.swing.GroupLayout.PREFERRED_SIZE, 446,
                                javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addContainerGap(35, Short.MAX_VALUE))
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
                        layout.createSequentialGroup().addGap(14, 14, 14).addComponent(back)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                                        javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(jLabel1).addGap(209, 209, 209)));
        layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(
                javax.swing.GroupLayout.Alignment.TRAILING,
                layout.createSequentialGroup().addGap(12, 12, 12)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jLabel1).addComponent(back))
                        .addGap(7, 7, 7)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(Desc, javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(ok1)
                                .addComponent(choice, javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jLabel3))
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(layout.createSequentialGroup().addGap(39, 39, 39)
                                        .addComponent(Desc2, javax.swing.GroupLayout.PREFERRED_SIZE, 22,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 105,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addGroup(layout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                .addComponent(jScrollPane2,
                                                        javax.swing.GroupLayout.Alignment.TRAILING,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addGroup(layout
                                                        .createParallelGroup(
                                                                javax.swing.GroupLayout.Alignment.BASELINE)
                                                        .addComponent(jButton2).addComponent(jButton1))))
                                .addGroup(
                                        layout.createSequentialGroup().addGap(22, 22, 22).addComponent(Categorical)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(Numerical).addGap(18, 18, 18).addComponent(jLabel4)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(Size, javax.swing.GroupLayout.PREFERRED_SIZE, 28,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(collapse)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(Chart)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(ok2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 102, Short.MAX_VALUE)
                        .addComponent(Warnings1, javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(16, 16, 16)));

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

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed

        List<String> Temp = new ArrayList<String>();
        List<String> check = new ArrayList<String>();
        List<Double> fnl = new ArrayList<>();
        List<String> frame = new ArrayList<String>();
        List<String> name = new ArrayList<String>();
        List<String> name2 = new ArrayList<String>();
        List<Double> frame2 = new ArrayList<Double>();
        List<Double> limitLeft = new ArrayList<>();
        List<Double> limitRight = new ArrayList<>();
        List<Double> trueLimitLeft = new ArrayList<>();
        List<Double> trueLimitRight = new ArrayList<>();
        List<Double> midpoint = new ArrayList<>();
        List<Integer> frequency = new ArrayList<>();
        List<Double> percent = new ArrayList<>();
        List<Integer> cf = new ArrayList<>();
        List<Double> cp = new ArrayList<>();

        Integer freq = 0;
        Double freqtot = 0.0;

        if (Categorical.isSelected() == true && Numerical.isSelected() == false) {
            for (int i = 0; i < jTable1.getRowCount(); i++) {
                frame.add((String) jTable1.getModel().getValueAt(i, 0));
            }
            Collections.sort(frame);

            Integer size = frame.size();
            System.out.println(size);
            for (Object b : frame) {
                String c = b + "";
                Temp.add(c);
            }

            for (int i = 0; i < jTable1.getRowCount(); i++) {
                for (int j = 0; j < jTable1.getColumnCount(); j++) {
                    jTable1.setValueAt("", i, j);
                }
            }

            int ct = 0;
            for (Object z : frame) {
                String a = z + "";
                System.out.print(check.contains(a));
                if (!(check.contains(a))) {
                    for (int i = 0; i < Temp.size(); i++) {
                        if (a.equals(Temp.get(i))) {
                            freq++;
                        }
                    }
                    Double freque = (((freq + .0) / size) * 100);
                    fnl.add(freque);
                    name.add(a);
                    freqtot += freque;
                    jTable1.getModel().setValueAt(a, ct, 0);
                    jTable1.getModel().setValueAt(String.format("%1.1f", freque) + "%", ct, 1);
                    ct++;
                    freq = 0;

                    check.add(a);
                }
                total.setText("Total :" + String.format("%1.1f", freqtot));
            }

            if (Chart.isSelected() == true) {
                DefaultPieDataset chart = new DefaultPieDataset();

                int h = 0;
                for (Double z : fnl) {
                    chart.setValue(name.get(h) + "", new Double(z));
                    h++;
                }
                JFreeChart mychart = ChartFactory.createPieChart3D(Desc.getText() + "", chart, true, true, true);
                PiePlot3D p = (PiePlot3D) mychart.getPlot();
                ChartFrame charteuFrame = new ChartFrame(Desc.getText(), mychart);
                charteuFrame.setVisible(true);
                charteuFrame.setSize(450, 500);
            }

        } else if (Numerical.isSelected() == true && Categorical.isSelected() == false) {
            double subtrahend = 0.5;

            for (int i = 0; i < jTable1.getRowCount();) {
                double d = Double.parseDouble((String) jTable1.getModel().getValueAt(i, 0));
                frame2.add(d);
                i++;
            }
            double max = 0;
            double min = frame2.get(0);
            for (int j = 0; j < frame2.size(); j++) {
                System.out.print("Sulod");
                if (max < frame2.get(j)) {
                    max = frame2.get(j);
                }
                if (min > frame2.get(j)) {
                    min = frame2.get(j);
                }
            }

            System.out.print(frame2);
            double range = max - min;
            double k = Math.ceil(1 + 3.322 * Math.log10(frame2.size()));
            int width = (int) Math.ceil(range / k);

            System.out.println("char:   " + max + " " + min + " " + range + " " + k + " width: " + width);
            double limit = min;
            while (limit < max) {
                limitLeft.add(limit);
                limit += width;
            }

            for (int j = 0; j < limitLeft.size(); j++) {
                System.out.print(limitLeft.get(j) + " ");
            }

            double limit2 = min + width - 1;
            while (limit2 <= max) {
                limitRight.add(limit2);
                limit2 += width;
            }

            if (limitRight.get(limitRight.size() - 1) != max) {
                limitRight.add(max);
            }

            System.out.println();
            for (int j = 0; j < limitRight.size(); j++) {
                System.out.print(limitRight.get(j) + " ");
            }

            //true limit
            if (((String) choice.getSelectedItem()).equals("Integer")) {

                for (int j = 0; j < limitLeft.size(); j++) {
                    trueLimitLeft.add(limitLeft.get(j) - 0.5);
                }

                System.out.println();
                for (int j = 0; j < trueLimitLeft.size(); j++) {
                    System.out.print(trueLimitLeft.get(j) + " ");
                }

                for (int j = 0; j < limitRight.size(); j++) {
                    trueLimitRight.add(limitRight.get(j) + 0.5);
                }

                System.out.println();
                for (int j = 0; j < trueLimitRight.size(); j++) {
                    System.out.print(trueLimitRight.get(j) + " ");
                }

            } else if (((String) choice.getSelectedItem()).equals("Floating")) {

                int count1 = 0;
                float diff = 0;
                boolean flag = false;

                for (int j = 0; j < frame2.size(); j++) {
                    double value = Math.floor(frame2.get(j));
                    //                    System.out.println(frame.get(j));
                    diff = (float) (frame2.get(j) - value);
                    System.out.println("diff: " + diff);
                    String counts = String.valueOf(diff);
                    if (diff > 0.0) {
                        if (counts.length() - 1 > count1) {
                            count1 = counts.length() - 1;
                            System.out.println(count1);
                        }
                    }
                }

                System.out.println(count1);

                for (int j = 0; j < count1 - 1; j++) {
                    subtrahend /= 10;
                    System.out.println(subtrahend);
                }

                System.out.println("sub: " + subtrahend);
                for (int j = 0; j < limitLeft.size(); j++) {
                    trueLimitLeft.add(limitLeft.get(j) - subtrahend);
                }

                for (int j = 0; j < limitRight.size(); j++) {
                    trueLimitRight.add(limitRight.get(j) + subtrahend);
                }
            }
            //midpoint
            for (int j = 0; j < limitLeft.size(); j++) {
                midpoint.add((limitLeft.get(j) + limitRight.get(j)) / 2);
            }

            System.out.println();
            for (int j = 0; j < midpoint.size(); j++) {
                System.out.print(midpoint.get(j) + " ");
            }

            //frequency
            for (int j = 0; j < limitLeft.size(); j++) {
                int count = 0;
                for (int m = 0; m < frame2.size(); m++) {
                    if (frame2.get(m) >= limitLeft.get(j) && frame2.get(m) <= limitRight.get(j)) {
                        count++;
                    }
                }
                frequency.add(count);
            }

            System.out.println();
            for (int j = 0; j < frequency.size(); j++) {
                System.out.print(frequency.get(j) + " ");
            }

            //percent
            for (int j = 0; j < frequency.size(); j++) {
                double pp = (((double) frequency.get(j) / frame2.size()) * 100);
                percent.add(pp);
            }

            System.out.println();
            for (int j = 0; j < percent.size(); j++) {
                System.out.print(percent.get(j) + " ");
            }

            int cff = 0;
            for (int j = 0; j < frequency.size(); j++) {
                cff += frequency.get(j);
                cf.add(cff);
            }

            System.out.println();
            for (int j = 0; j < cf.size(); j++) {
                System.out.print(cf.get(j) + " ");
            }

            double cpp = 0;
            for (int j = 0; j < percent.size(); j++) {
                cpp += percent.get(j);
                cp.add(cpp);
            }

            System.out.println();

            for (int j = 0; j < cp.size(); j++) {
                System.out.print(cp.get(j) + " ");
            }

            DefaultTableModel dtm = (DefaultTableModel) jTable1.getModel();
            dtm.setRowCount(limitLeft.size());

            int ct = 0;
            if (collapse.isSelected() == true) {
                for (int j = 0; j < limitLeft.size(); j++) {
                    if (ct == 0) {
                        jTable1.getModel().setValueAt("< " + limitRight.get(j), ct, 1);
                        jTable1.getModel().setValueAt("-", ct, 3);
                        name.add("<");
                    } else if (ct == limitLeft.size() - 1) {
                        jTable1.getModel().setValueAt("> " + limitLeft.get(j), ct, 1);
                        jTable1.getModel().setValueAt("-", ct, 3);
                        name.add(">");
                    } else {
                        jTable1.getModel().setValueAt(limitLeft.get(j) + "-" + limitRight.get(j), ct, 1);
                        jTable1.getModel().setValueAt(midpoint.get(j), ct, 3);
                        name.add(midpoint.get(j) + "");
                    }
                    jTable1.getModel().setValueAt(trueLimitLeft.get(j) + "-" + trueLimitRight.get(j), ct, 2);
                    jTable1.getModel().setValueAt(frequency.get(j), ct, 4);
                    jTable1.getModel().setValueAt(percent.get(j), ct, 5);
                    jTable1.getModel().setValueAt(cf.get(j), ct, 6);
                    jTable1.getModel().setValueAt(cp.get(j), ct, 7);
                    ct++;
                }

            } else {
                for (int j = 0; j < limitLeft.size(); j++) {

                    jTable1.getModel().setValueAt(limitLeft.get(j) + "-" + limitRight.get(j), ct, 1);
                    jTable1.getModel().setValueAt(trueLimitLeft.get(j) + "-" + trueLimitRight.get(j), ct, 2);
                    jTable1.getModel().setValueAt(midpoint.get(j), ct, 3);
                    name.add(midpoint.get(j) + "");
                    jTable1.getModel().setValueAt(frequency.get(j), ct, 4);
                    jTable1.getModel().setValueAt(percent.get(j), ct, 5);
                    jTable1.getModel().setValueAt(cf.get(j), ct, 6);
                    jTable1.getModel().setValueAt(cp.get(j), ct, 7);
                    ct++;
                }
            }
            if (Chart.isSelected() == true) {
                DefaultCategoryDataset chart = new DefaultCategoryDataset();

                int h = 0;
                for (Integer z : frequency) {
                    chart.setValue(z, "Frequency", name.get(h));
                    h++;
                }
                JFreeChart mychart = ChartFactory.createBarChart(Desc.getText() + "", "Midpoint", "Frequency",
                        chart, PlotOrientation.VERTICAL, true, false, false);
                CategoryPlot p = (CategoryPlot) mychart.getPlot();
                p.setDomainGridlinesVisible(true);
                p.getDomainAxis().setCategoryMargin(0.0);
                ChartFrame charteuFrame = new ChartFrame(Desc.getText(), mychart);
                charteuFrame.setVisible(true);
                charteuFrame.setSize(450, 500);
            }
        }
    }//GEN-LAST:event_jButton1ActionPerformed

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

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        for (int i = 0; i < jTable1.getRowCount(); i++) {
            for (int j = 0; j < jTable1.getColumnCount(); j++) {
                jTable1.setValueAt("", i, j);
            }
        }
        total.setText("");
        Warnings1.setText("");
    }//GEN-LAST:event_jButton2ActionPerformed

    private void CategoricalActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CategoricalActionPerformed

    }//GEN-LAST:event_CategoricalActionPerformed

    private void ok1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ok1ActionPerformed
        Desc2.setText(Desc.getText());
    }//GEN-LAST:event_ok1ActionPerformed

    private void backActionPerformed(java.awt.event.ActionEvent evt) {
        this.setVisible(false);
        new MainMenu().setVisible(true);
    }

    private void SizeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SizeActionPerformed

    }//GEN-LAST:event_SizeActionPerformed

    private void ok2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ok2ActionPerformed
        Integer size = 0;
        System.out.println("Nisulod");
        try {
            size = Integer.parseInt(Size.getText());
        } catch (Exception e) {
            Warnings.setText("Invalid size");
        }
        Warnings1.setText("");
        if (Categorical.isSelected() == true && Numerical.isSelected() == false) {
            String header[] = { "Values", "Percentage" };
            DefaultTableModel dtm = (DefaultTableModel) jTable1.getModel();
            dtm.setRowCount(size);
            dtm.setColumnCount(2);

            for (int i = 0; i < jTable1.getColumnCount(); i++) {
                TableColumn column1 = jTable1.getTableHeader().getColumnModel().getColumn(i);
                column1.setHeaderValue(header[i]);
            }
        } //GEN-LAST:event_ok2ActionPerformed
        else if (Numerical.isSelected() == true && Categorical.isSelected() == false) {
            String header[] = { "VAL", "CL", "True CL", "MP", "FQ", "%", "CF", "C%" };
            DefaultTableModel dtm = (DefaultTableModel) jTable1.getModel();
            dtm.setRowCount(size);
            dtm.setColumnCount(8);

            for (int i = 0; i < jTable1.getColumnCount(); i++) {
                TableColumn column1 = jTable1.getTableHeader().getColumnModel().getColumn(i);
                column1.setHeaderValue(header[i]);
            }
        } else {
            Warnings1.setText("Select one operation");
        }
    }

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

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

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JRadioButton Categorical;
    private javax.swing.JCheckBox Chart;
    private javax.swing.JTextField Desc;
    private javax.swing.JLabel Desc2;
    private javax.swing.JRadioButton Numerical;
    private javax.swing.JTextField Size;
    private javax.swing.JTextField Warnings;
    private javax.swing.JTextField Warnings1;
    private javax.swing.JButton back;
    private javax.swing.JComboBox<String> choice;
    private javax.swing.JCheckBox collapse;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JTable jTable1;
    private javax.swing.JButton ok1;
    private javax.swing.JButton ok2;
    private javax.swing.JTextPane total;
    // End of variables declaration//GEN-END:variables
}