sofmeth.mco3.gui.SETFrame.java Source code

Java tutorial

Introduction

Here is the source code for sofmeth.mco3.gui.SETFrame.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 sofmeth.mco3.gui;

import java.io.File;
import java.io.FileOutputStream;
import java.math.BigInteger;
import org.apache.poi.xwpf.usermodel.ParagraphAlignment;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.apache.poi.xwpf.usermodel.XWPFParagraph;
import org.apache.poi.xwpf.usermodel.XWPFRun;
import org.apache.poi.xwpf.usermodel.XWPFTable;
import org.apache.poi.xwpf.usermodel.XWPFTableRow;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTblWidth;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STTblWidth;

/**
 *
 * @author owner
 */
public class SETFrame extends javax.swing.JFrame {

    /**
     * Creates new form SETFrame
     */
    private String nameField, profField, progField, progNumField, dateField, langField;
    private int bSize, locDeleted, locMod, totalBase, totalNew, reTotal, pLoc, esNew, esTotal = 0;

    public SETFrame() {
        initComponents();
    }

    public SETFrame(String comboValue, String nameField, String profField, String progField, String progNumField,
            String dateField, String langField) {
        initComponents();
        this.setVisible(true);
        this.nameField = nameField;
        this.profField = profField;
        this.progField = progField;
        this.progNumField = progNumField;
        this.dateField = dateField;
        this.langField = langField;
    }

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

        jLabel5 = new javax.swing.JLabel();
        jPanel1 = new javax.swing.JPanel();
        jLabel6 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        modField = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        delField = new javax.swing.JTextField();
        baseField = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        locTable = new javax.swing.JTable();
        jLabel7 = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        noTable = new javax.swing.JTable();
        jLabel8 = new javax.swing.JLabel();
        jScrollPane3 = new javax.swing.JScrollPane();
        roTable = new javax.swing.JTable();
        closeButton = new javax.swing.JButton();
        doneButton = new javax.swing.JButton();
        jLabel9 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        b0Field = new javax.swing.JTextField();
        b1Field = new javax.swing.JTextField();

        jLabel5.setText("jLabel5");

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jLabel6.setText("Projected LOC");

        jLabel4.setText("LOC Modified");

        jLabel3.setText("LOC Deleted");

        jLabel2.setText("Base Size");

        jLabel1.setText("Base Program");

        locTable.setModel(new javax.swing.table.DefaultTableModel(
                new Object[][] { { null, null, null, null, null }, { null, null, null, null, null },
                        { null, null, null, null, null }, { null, null, null, null, null },
                        { null, null, null, null, null }, { null, null, null, null, null },

                }, new String[] { "Base Additions", "Type", "Methods", "Relative Size", "LOC" }));
        jScrollPane1.setViewportView(locTable);

        jLabel7.setText("New Objects");

        noTable.setModel(new javax.swing.table.DefaultTableModel(
                new Object[][] { { null, null, null, null, null }, { null, null, null, null, null },
                        { null, null, null, null, null }, { null, null, null, null, null },
                        { null, null, null, null, null }, { null, null, null, null, null },
                        { null, null, null, null, null }, { null, null, null, null, null },
                        { null, null, null, null, null }, { null, null, null, null, null },
                        { null, null, null, null, null }, { null, null, null, null, null },
                        { null, null, null, null, null }, { null, null, null, null, null },
                        { null, null, null, null, null }, { null, null, null, null, null },
                        { null, null, null, null, null }, { null, null, null, null, null },
                        { null, null, null, null, null } },
                new String[] { "New Objects", "Type", "Methods", "Relative Size", "LOC" }));
        jScrollPane2.setViewportView(noTable);

        jLabel8.setText("Resued Objects");

        roTable.setModel(new javax.swing.table.DefaultTableModel(new Object[][] { { null, null }, { null, null },
                { null, null }, { null, null }, { null, null }, { null, null },

        }, new String[] { "Reused Objects", "LOC" }));
        jScrollPane3.setViewportView(roTable);

        closeButton.setText("Close");
        closeButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                closeButtonActionPerformed(evt);
            }
        });

        doneButton.setText("Done");
        doneButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                doneButtonActionPerformed(evt);
            }
        });

        jLabel9.setText("Regression Parameter (B0)");

        jLabel10.setText("Regression Parameter (B1)");

        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().addGroup(jPanel1Layout
                        .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(jPanel1Layout.createSequentialGroup().addGap(0, 0, Short.MAX_VALUE)
                                .addComponent(doneButton)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(closeButton))
                        .addGroup(jPanel1Layout.createSequentialGroup().addGroup(jPanel1Layout
                                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jLabel1)
                                .addGroup(jPanel1Layout.createSequentialGroup().addGroup(jPanel1Layout
                                        .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGroup(jPanel1Layout
                                                .createParallelGroup(
                                                        javax.swing.GroupLayout.Alignment.LEADING, false)
                                                .addComponent(jLabel6)
                                                .addGroup(jPanel1Layout.createSequentialGroup()
                                                        .addComponent(jLabel4).addGap(18, 18, 18).addComponent(
                                                                modField, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                                40, javax.swing.GroupLayout.PREFERRED_SIZE))
                                                .addGroup(jPanel1Layout.createSequentialGroup()
                                                        .addGroup(jPanel1Layout
                                                                .createParallelGroup(
                                                                        javax.swing.GroupLayout.Alignment.LEADING)
                                                                .addComponent(jLabel3).addComponent(jLabel2))
                                                        .addPreferredGap(
                                                                javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                Short.MAX_VALUE)
                                                        .addGroup(jPanel1Layout
                                                                .createParallelGroup(
                                                                        javax.swing.GroupLayout.Alignment.LEADING)
                                                                .addComponent(delField,
                                                                        javax.swing.GroupLayout.Alignment.TRAILING,
                                                                        javax.swing.GroupLayout.PREFERRED_SIZE, 40,
                                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                                .addComponent(baseField,
                                                                        javax.swing.GroupLayout.Alignment.TRAILING,
                                                                        javax.swing.GroupLayout.PREFERRED_SIZE, 40,
                                                                        javax.swing.GroupLayout.PREFERRED_SIZE))))
                                        .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addGap(20, 20, 20)
                                        .addGroup(jPanel1Layout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                .addComponent(jLabel7)
                                                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addGroup(jPanel1Layout
                                                        .createParallelGroup(
                                                                javax.swing.GroupLayout.Alignment.TRAILING, false)
                                                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING,
                                                                jPanel1Layout.createSequentialGroup()
                                                                        .addComponent(jLabel10)
                                                                        .addPreferredGap(
                                                                                javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                                                        .addComponent(b1Field))
                                                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING,
                                                                jPanel1Layout.createSequentialGroup()
                                                                        .addComponent(jLabel9)
                                                                        .addPreferredGap(
                                                                                javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                                                        .addComponent(b0Field,
                                                                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                                                                90,
                                                                                javax.swing.GroupLayout.PREFERRED_SIZE)))))
                                .addComponent(jLabel8)).addGap(0, 47, Short.MAX_VALUE)))
                        .addContainerGap()));
        jPanel1Layout.setVerticalGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel1Layout.createSequentialGroup().addGap(19, 19, 19).addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(baseField, javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jLabel2))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 14,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(delField, javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(modField, javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jLabel4))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jLabel6).addComponent(jLabel7))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 209,
                                        Short.MAX_VALUE)
                                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 0,
                                        Short.MAX_VALUE))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(jPanel1Layout.createSequentialGroup().addComponent(jLabel8)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addGroup(jPanel1Layout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                .addGroup(jPanel1Layout.createSequentialGroup()
                                                        .addGroup(jPanel1Layout.createParallelGroup(
                                                                javax.swing.GroupLayout.Alignment.BASELINE)
                                                                .addComponent(jLabel9).addComponent(b0Field,
                                                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                                                        .addPreferredGap(
                                                                javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                        .addGroup(jPanel1Layout
                                                                .createParallelGroup(
                                                                        javax.swing.GroupLayout.Alignment.BASELINE)
                                                                .addComponent(jLabel10).addComponent(b1Field,
                                                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                        javax.swing.GroupLayout.PREFERRED_SIZE)))
                                                .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        227, javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addGap(23, 23, 23))
                                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout
                                        .createSequentialGroup().addGap(0, 0, Short.MAX_VALUE)
                                        .addGroup(jPanel1Layout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                                .addComponent(closeButton).addComponent(doneButton))
                                        .addGap(11, 11, 11)))));

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                        .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(0, 0, Short.MAX_VALUE)));
        layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                        .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(0, 0, Short.MAX_VALUE)));

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

    private void closeButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_closeButtonActionPerformed
        // TODO add your handling code here:
        this.setVisible(false);
    }//GEN-LAST:event_closeButtonActionPerformed

    private void doneButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_doneButtonActionPerformed
        // TODO add your handling code here:
        XWPFDocument document = new XWPFDocument();
        try {
            FileOutputStream out = new FileOutputStream(new File("size estimating template.docx"));
            //making of title
            XWPFParagraph para = document.createParagraph();
            para.setAlignment(ParagraphAlignment.CENTER);
            para.setSpacingAfter(500);
            XWPFRun run = para.createRun();
            run.setText("Size Estimating Template");
            run.setBold(true);
            run.setFontSize(16);
            //end making of title
            //adding name etc to document
            XWPFTable details = document.createTable(2, 2);
            //setting cell width
            CTTblWidth width = details.getCTTbl().addNewTblPr().addNewTblW();
            width.setType(STTblWidth.DXA);
            width.setW(BigInteger.valueOf(9500));
            //end setting cell width
            //details.getCTTbl().getTblPr().unsetTblBorders();
            XWPFTableRow dtlRow = details.getRow(0);
            dtlRow.getCell(0).setText("Name: " + nameField);
            dtlRow.getCell(1).setText("Date: " + dateField);
            dtlRow = details.getRow(1);
            dtlRow.getCell(0).setText("Professor: " + profField);
            dtlRow.getCell(1).setText("Program#: " + progNumField);
            //end adding name to document
            para = document.createParagraph();
            run = para.createRun();
            run.addBreak();
            run.addBreak();

            //computation
            for (int i = 0; i < 6; i++) {

                if (locTable.getModel().getValueAt(i, 4) != null
                        && !locTable.getModel().getValueAt(i, 4).toString().isEmpty()) {

                    bSize = bSize + Integer.parseInt(locTable.getModel().getValueAt(i, 4).toString());
                }

            }
            for (int i = 0; i < 6; i++) {

                if (noTable.getModel().getValueAt(i, 4) != null
                        && !noTable.getModel().getValueAt(i, 4).toString().isEmpty()) {

                    totalNew = totalNew + Integer.parseInt(noTable.getModel().getValueAt(i, 4).toString());
                }

            }
            for (int i = 0; i < 6; i++) {

                if (roTable.getModel().getValueAt(i, 1) != null
                        && !roTable.getModel().getValueAt(i, 1).toString().isEmpty()) {

                    reTotal = reTotal + Integer.parseInt(roTable.getModel().getValueAt(i, 1).toString());
                }

            }

            pLoc = bSize + totalNew;
            int b0 = Integer.parseInt(b0Field.getText());
            int b1 = Integer.parseInt(b1Field.getText());
            esNew = b0 + b1 * (pLoc + locMod);
            esTotal = esNew + bSize - locDeleted - locMod + reTotal;
            //

            //creating of TPT table
            XWPFTable table = document.createTable(1, 1);
            width = table.getCTTbl().addNewTblPr().addNewTblW();
            width.setType(STTblWidth.DXA);
            width.setW(BigInteger.valueOf(9500));

            XWPFTableRow row = table.getRow(0);
            row.getCell(0).setText("Base Program");

            table = document.createTable(3, 2);

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

                row = table.getRow(i);
                switch (i) {
                case 0:
                    row.getCell(0).setText("Base Size(B)");
                    row.getCell(1).setText(baseField.getText());
                    break;
                case 1:
                    row.getCell(0).setText("LOC Deleted(D)");
                    row.getCell(1).setText(delField.getText());
                    break;
                case 2:
                    row.getCell(0).setText("LOC Modified(M)");
                    row.getCell(1).setText(modField.getText());
                    break;
                }
            }

            para = document.createParagraph();
            run = para.createRun();
            table = document.createTable(1, 1);
            width = table.getCTTbl().addNewTblPr().addNewTblW();
            width.setType(STTblWidth.DXA);
            width.setW(BigInteger.valueOf(9500));
            row = table.getRow(0);
            row.getCell(0).setText("Projected LOC (P)");

            table = document.createTable(7, 5);

            for (int i = -1; i < 6; i++) {

                if (i == 5)
                    break;
                if (i == -1) { //top row of the table
                    XWPFTableRow row1 = table.getRow(i + 1);
                    for (int j = 0; j < 5; j++) {

                        switch (j) { //no formatting yet like bold etc
                        case 0:
                            row1.getCell(j).setText("Base Additions");
                            break;
                        case 1:
                            row1.getCell(j).setText("Type");
                            break;
                        case 2:
                            row1.getCell(j).setText("Methods");
                            break;
                        case 3:
                            row1.getCell(j).setText("Relative Size");
                            break;
                        case 4:
                            row1.getCell(j).setText("LOC");
                            break;

                        }

                    }
                }
                //although this code assumes that there are values inside
                //UPDATE1: ok i fixed it i think
                else {
                    row = table.getRow(i + 1);
                    for (int j = 0; j < 5; j++) {
                        if (locTable.getModel().getValueAt(i, 1) != null
                                && !locTable.getModel().getValueAt(i, j).toString().isEmpty()) {

                            if (locTable.getModel().getValueAt(i, j) != null
                                    && !locTable.getModel().getValueAt(i, j).toString().isEmpty())

                                row.getCell(j).setText(locTable.getModel().getValueAt(i, j).toString());
                        } else
                            break;
                    }
                }

            }

            System.out.print(bSize);

            table = document.createTable(1, 2);
            row = table.getRow(0);
            row.getCell(0).setText("Total Base Additions(BA)");
            row.getCell(1).setText(Integer.toString(bSize));

            para = document.createParagraph();
            run = para.createRun();

            table = document.createTable(7, 5);
            width = table.getCTTbl().addNewTblPr().addNewTblW();
            width.setType(STTblWidth.DXA);
            width.setW(BigInteger.valueOf(9500));
            for (int i = -1; i < 6; i++) {

                if (i == 5)
                    break;
                if (i == -1) { //top row of the table
                    XWPFTableRow row1 = table.getRow(i + 1);
                    for (int j = 0; j < 5; j++) {

                        switch (j) { //no formatting yet like bold etc
                        case 0:
                            row1.getCell(j).setText("New Objects(NO)");
                            break;
                        case 1:
                            row1.getCell(j).setText("Type");
                            break;
                        case 2:
                            row1.getCell(j).setText("Methods");
                            break;
                        case 3:
                            row1.getCell(j).setText("Relative Size");
                            break;
                        case 4:
                            row1.getCell(j).setText("LOC");
                            break;

                        }

                    }
                }
                //although this code assumes that there are values inside
                //UPDATE1: ok i fixed it i think
                else {
                    row = table.getRow(i + 1);
                    for (int j = 0; j < 5; j++) {
                        if (noTable.getModel().getValueAt(i, 1) != null
                                && !noTable.getModel().getValueAt(i, j).toString().isEmpty()) {

                            if (noTable.getModel().getValueAt(i, j) != null
                                    && !noTable.getModel().getValueAt(i, j).toString().isEmpty())

                                row.getCell(j).setText(noTable.getModel().getValueAt(i, j).toString());
                        } else
                            break;
                    }
                }

            }
            table = document.createTable(1, 2);
            row = table.getRow(0);
            row.getCell(0).setText("Total New Objects(NO)");
            row.getCell(1).setText(Integer.toString(totalNew));

            para = document.createParagraph();
            //para.setPageBreak(true);

            table = document.createTable(7, 2);
            width = table.getCTTbl().addNewTblPr().addNewTblW();
            width.setType(STTblWidth.DXA);
            width.setW(BigInteger.valueOf(9500));
            for (int i = -1; i < 6; i++) {

                if (i == 6)
                    break;
                if (i == -1) { //top row of the table
                    XWPFTableRow row1 = table.getRow(i + 1);
                    for (int j = 0; j < 2; j++) {

                        switch (j) { //no formatting yet like bold etc
                        case 0:
                            row1.getCell(j).setText("Reused Objects");
                            break;
                        case 1:
                            row1.getCell(j).setText("LOC");
                            break;

                        }

                    }
                }
                //although this code assumes that there are values inside
                //UPDATE1: ok i fixed it i think
                else {
                    row = table.getRow(i + 1);
                    for (int j = 0; j < 2; j++) {
                        if (roTable.getModel().getValueAt(i, 1) != null
                                && !roTable.getModel().getValueAt(i, j).toString().isEmpty()) {

                            if (roTable.getModel().getValueAt(i, j) != null
                                    && !roTable.getModel().getValueAt(i, j).toString().isEmpty())

                                row.getCell(j).setText(roTable.getModel().getValueAt(i, j).toString());
                        } else
                            break;
                    }
                }

            }
            table = document.createTable(1, 2);
            row = table.getRow(0);
            row.getCell(0).setText("Reused Total(R)");
            row.getCell(1).setText(Integer.toString(reTotal));

            para = document.createParagraph();
            table = document.createTable(5, 2);
            width = table.getCTTbl().addNewTblPr().addNewTblW();
            width.setType(STTblWidth.DXA);
            width.setW(BigInteger.valueOf(9500));

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

                row = table.getRow(i);
                switch (i) {
                case 0:
                    row.getCell(0).setText("Projected LOC(P)");
                    row.getCell(1).setText(Integer.toString(pLoc));
                    break;
                case 1:
                    row.getCell(0).setText("Regression Parameter(B0)");
                    row.getCell(1).setText(Integer.toString(b0));
                    break;
                case 2:
                    row.getCell(0).setText("Regression Parameter(B1)");
                    row.getCell(1).setText(Integer.toString(b1));
                    break;
                case 3:
                    row.getCell(0).setText("Estimated New and Changed LOC(N)");
                    row.getCell(1).setText(Integer.toString(esNew));
                    break;
                case 4:
                    row.getCell(0).setText("Estimated Total LOC(T)");
                    row.getCell(1).setText(Integer.toString(esTotal));
                    break;
                }
            }

            document.write(out);
            out.close();

        } catch (Exception e) {

        }

    }//GEN-LAST:event_doneButtonActionPerformed

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

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextField b0Field;
    private javax.swing.JTextField b1Field;
    private javax.swing.JTextField baseField;
    private javax.swing.JButton closeButton;
    private javax.swing.JTextField delField;
    private javax.swing.JButton doneButton;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JTable locTable;
    private javax.swing.JTextField modField;
    private javax.swing.JTable noTable;
    private javax.swing.JTable roTable;
    // End of variables declaration//GEN-END:variables
}