Example usage for org.apache.poi.xwpf.usermodel XWPFParagraph setAlignment

List of usage examples for org.apache.poi.xwpf.usermodel XWPFParagraph setAlignment

Introduction

In this page you can find the example usage for org.apache.poi.xwpf.usermodel XWPFParagraph setAlignment.

Prototype

public void setAlignment(ParagraphAlignment align) 

Source Link

Document

Specifies the paragraph alignment which shall be applied to text in this paragraph.

Usage

From source file:org.cgiar.ccafs.marlo.utils.POISummary.java

License:Open Source License

public void textTable(XWPFDocument document, List<List<POIField>> sHeaders, List<List<POIField>> sData,
        Boolean highlightFirstColumn, String tableType) {
    XWPFTable table = document.createTable();
    int record = 0;
    int headerIndex = 0;
    for (List<POIField> poiParameters : sHeaders) {

        // Setting the Header
        XWPFTableRow tableRowHeader;/*w w  w.  j a v a  2  s  .c  o  m*/
        if (headerIndex == 0) {
            tableRowHeader = table.getRow(0);
        } else {
            tableRowHeader = table.createRow();
        }
        for (POIField poiParameter : poiParameters) {

            // Condition for table b cell color in fields 5 and 6
            if (tableType.equals("tableBAnnualReport") && (record == 4 || record == 5)) {
                TABLE_HEADER_FONT_COLOR = "DEEAF6";
            } else {
                TABLE_HEADER_FONT_COLOR = "FFF2CC";
            }

            if (headerIndex == 0) {
                if (record == 0) {
                    XWPFParagraph paragraph = tableRowHeader.getCell(0).addParagraph();
                    paragraph.setAlignment(poiParameter.getAlignment());
                    XWPFRun paragraphRun = paragraph.createRun();
                    this.addParagraphTextBreak(paragraphRun, poiParameter.getText());
                    paragraphRun.setColor(TEXT_FONT_COLOR);
                    if (poiParameter.getBold() != null) {
                        paragraphRun.setBold(poiParameter.getBold());
                    } else {
                        paragraphRun.setBold(true);
                    }
                    paragraphRun.setFontFamily(FONT_TYPE);
                    paragraphRun.setFontSize(TABLE_TEXT_FONT_SIZE);

                    tableRowHeader.getCell(record).setColor(TABLE_HEADER_FONT_COLOR);
                } else {
                    XWPFParagraph paragraph = tableRowHeader.createCell().addParagraph();
                    paragraph.setAlignment(poiParameter.getAlignment());
                    XWPFRun paragraphRun = paragraph.createRun();
                    this.addParagraphTextBreak(paragraphRun, poiParameter.getText());
                    paragraphRun.setColor(TEXT_FONT_COLOR);
                    if (poiParameter.getBold() != null) {
                        paragraphRun.setBold(poiParameter.getBold());
                    } else {
                        paragraphRun.setBold(true);
                    }
                    paragraphRun.setFontFamily(FONT_TYPE);
                    paragraphRun.setFontSize(TABLE_TEXT_FONT_SIZE);

                    tableRowHeader.getCell(record).setColor(TABLE_HEADER_FONT_COLOR);
                }
            } else {
                XWPFParagraph paragraph = tableRowHeader.getCell(record).addParagraph();
                paragraph.setAlignment(poiParameter.getAlignment());
                XWPFRun paragraphRun = paragraph.createRun();
                this.addParagraphTextBreak(paragraphRun, poiParameter.getText());
                paragraphRun.setColor(TEXT_FONT_COLOR);
                if (poiParameter.getBold() != null) {
                    paragraphRun.setBold(poiParameter.getBold());
                } else {
                    paragraphRun.setBold(true);
                }
                paragraphRun.setFontFamily(FONT_TYPE);
                paragraphRun.setFontSize(TABLE_TEXT_FONT_SIZE);

                tableRowHeader.getCell(record).setColor(TABLE_HEADER_FONT_COLOR);
            }
            record++;
        }
        headerIndex++;
        record = 0;
    }

    for (List<POIField> poiParameters : sData) {
        record = 0;

        // Condition for table b cell color in fields 5 and 6
        if (tableType.equals("tableBAnnualReport") && (record == 4 || record == 5)) {
            TABLE_HEADER_FONT_COLOR = "DEEAF6";
        } else {
            TABLE_HEADER_FONT_COLOR = "FFF2CC";
        }

        XWPFTableRow dataRow = table.createRow();
        for (POIField poiParameter : poiParameters) {
            count++;
            XWPFParagraph paragraph = dataRow.getCell(record).addParagraph();
            paragraph.setAlignment(poiParameter.getAlignment());
            // Hyperlink
            if (poiParameter.getUrl() != null && !poiParameter.getUrl().isEmpty()) {
                this.textHyperlink(poiParameter.getUrl(), poiParameter.getText(), paragraph);
            } else {
                XWPFRun paragraphRun = paragraph.createRun();
                this.addParagraphTextBreak(paragraphRun, poiParameter.getText());
                if (poiParameter.getFontColor() != null) {
                    paragraphRun.setColor(poiParameter.getFontColor());
                } else {
                    paragraphRun.setColor(TEXT_FONT_COLOR);
                }
                paragraphRun.setFontFamily(FONT_TYPE);
                paragraphRun.setFontSize(TABLE_TEXT_FONT_SIZE);

                // Condition for table b cell color in fields 5 and 6
                if (tableType.equals("tableBAnnualReport") && (record == 4 || record == 5)) {
                    TABLE_HEADER_FONT_COLOR = "DEEAF6";
                    dataRow.getCell(record).setColor("DEEAF6");
                } else {
                    TABLE_HEADER_FONT_COLOR = "FFF2CC";
                }

                // highlight and bold first and SecondColumn for table D1
                if (tableType.equals("tableD1AnnualReport") && (record == 0 || record == 1) && count < 9) {
                    dataRow.getCell(record).setColor("DEEAF6");
                    paragraphRun.setBold(true);
                } else if (tableType.equals("tableD1AnnualReport") && count >= 9
                        && (record == 0 || record == 1)) {
                    dataRow.getCell(record).setColor("E2EFD9");
                    paragraphRun.setBold(true);

                } else {
                    if (highlightFirstColumn && record == 0) {
                        dataRow.getCell(record).setColor(TABLE_HEADER_FONT_COLOR);
                        if (poiParameter.getBold() != null) {
                            paragraphRun.setBold(poiParameter.getBold());
                        } else {
                            paragraphRun.setBold(true);
                        }
                    } else {
                        if (poiParameter.getBold() != null) {
                            paragraphRun.setBold(poiParameter.getBold());
                        } else {
                            paragraphRun.setBold(false);
                        }
                    }
                }

            }
            record++;
        }

    }

    switch (tableType) {
    case "tableA":
        this.tableAStyle(table);
        break;
    case "tableE":
        this.tableEStyle(table);
        break;
    case "tableC":
        this.tableCStyle(table);
        break;
    case "tableF":
        this.tableFStyle(table);
        break;
    case "tableG":
        this.tableGStyle(table);
        break;

    case "tableAAnnualReport":
        this.tableBAnnualReportStyle(table);
        break;
    case "tableA1AnnualReport":
        this.tableA1AnnualReportStyle(table);
        break;
    case "tableA2AnnualReport":
        this.tableA1AnnualReportStyle(table);
        break;
    case "tableBAnnualReport":
        this.tableBAnnualReportStyle(table);
        break;
    case "tableCAnnualReport":
        count = 0;
        this.tableCStyle(table);
        break;
    case "tableD1AnnualReport":
        this.tableD1AnnualReportStyle(table);
        break;
    case "tableD2AnnualReport":
        count = 0;
        this.tableAStyle(table);
        break;
    case "tableEAnnualReport":
        this.tableGStyle(table);
        break;
    case "tableFAnnualReport":
        this.tableFStyle(table);
        break;
    case "tableGAnnualReport":
        this.tableGStyle(table);
        break;
    case "tableHAnnualReport":
        this.tableGStyle(table);
        break;
    case "tableIAnnualReport":
        this.tableIAnnualReportStyle(table);
        break;
    case "tableJAnnualReport":
        this.tableJAnnualReportStyle(table);
        break;
    }
    if (tableType.contains("AnnualReport")) {
        table.getCTTbl().addNewTblPr().addNewTblW().setW(BigInteger.valueOf(13350));
    } else {
        table.getCTTbl().addNewTblPr().addNewTblW().setW(BigInteger.valueOf(12000));
    }

}

From source file:org.robert.study.service.merge.doc.SimpleDocument.java

License:Apache License

public static void main(String[] args) throws Exception {
    XWPFDocument doc = new XWPFDocument();

    XWPFParagraph p1 = doc.createParagraph();
    p1.setAlignment(ParagraphAlignment.CENTER);
    p1.setBorderBottom(Borders.DOUBLE);/*from w  w  w .  ja  v  a 2 s. co m*/
    p1.setBorderTop(Borders.DOUBLE);

    p1.setBorderRight(Borders.DOUBLE);
    p1.setBorderLeft(Borders.DOUBLE);
    p1.setBorderBetween(Borders.SINGLE);

    p1.setVerticalAlignment(TextAlignment.TOP);

    XWPFRun r1 = p1.createRun();
    r1.setBold(true);
    r1.setText("The quick brown fox");
    r1.setBold(true);
    r1.setFontFamily("Courier");
    r1.setUnderline(UnderlinePatterns.DOT_DOT_DASH);
    r1.setTextPosition(100);

    XWPFParagraph p2 = doc.createParagraph();
    p2.setAlignment(ParagraphAlignment.RIGHT);

    // BORDERS
    p2.setBorderBottom(Borders.DOUBLE);
    p2.setBorderTop(Borders.DOUBLE);
    p2.setBorderRight(Borders.DOUBLE);
    p2.setBorderLeft(Borders.DOUBLE);
    p2.setBorderBetween(Borders.SINGLE);

    XWPFRun r2 = p2.createRun();
    r2.setText("jumped over the lazy dog");
    r2.setStrike(true);
    r2.setFontSize(20);

    XWPFRun r3 = p2.createRun();
    r3.setText("and went away");
    r3.setStrike(true);
    r3.setFontSize(20);
    r3.setSubscript(VerticalAlign.SUPERSCRIPT);

    XWPFParagraph p3 = doc.createParagraph();
    p3.setWordWrap(true);
    p3.setPageBreak(true);

    // p3.setAlignment(ParagraphAlignment.DISTRIBUTE);
    p3.setAlignment(ParagraphAlignment.BOTH);
    p3.setSpacingLineRule(LineSpacingRule.EXACT);

    p3.setIndentationFirstLine(600);

    XWPFRun r4 = p3.createRun();
    r4.setTextPosition(20);
    r4.setText("To be, or not to be: that is the question: " + "Whether 'tis nobler in the mind to suffer "
            + "The slings and arrows of outrageous fortune, " + "Or to take arms against a sea of troubles, "
            + "And by opposing end them? To die: to sleep; ");
    r4.addBreak(BreakType.PAGE);
    r4.setText("No more; and by a sleep to say we end " + "The heart-ache and the thousand natural shocks "
            + "That flesh is heir to, 'tis a consummation " + "Devoutly to be wish'd. To die, to sleep; "
            + "To sleep: perchance to dream: ay, there's the rub; " + ".......");
    r4.setItalic(true);
    // This would imply that this break shall be treated as a simple line
    // break, and break the line after that word:

    XWPFRun r5 = p3.createRun();
    r5.setTextPosition(-10);
    r5.setText("For in that sleep of death what dreams may come");
    r5.addCarriageReturn();
    r5.setText("When we have shuffled off this mortal coil," + "Must give us pause: there's the respect"
            + "That makes calamity of so long life;");
    r5.addBreak();
    r5.setText("For who would bear the whips and scorns of time,"
            + "The oppressor's wrong, the proud man's contumely,");

    r5.addBreak(BreakClear.ALL);
    r5.setText("The pangs of despised love, the law's delay," + "The insolence of office and the spurns"
            + ".......");

    FileOutputStream out = new FileOutputStream("z://simple.docx");
    doc.write(out);
    out.close();

}

From source file:ParserDoc.SimpleDocument.java

License:Apache License

public static void main(String[] args) throws Exception {
    XWPFDocument doc = new XWPFDocument();

    XWPFParagraph p1 = doc.createParagraph();
    p1.setAlignment(ParagraphAlignment.CENTER);
    p1.setBorderBottom(Borders.DOUBLE);//from ww  w  .  j av  a  2s  .  com
    p1.setBorderTop(Borders.DOUBLE);

    p1.setBorderRight(Borders.DOUBLE);
    p1.setBorderLeft(Borders.DOUBLE);
    p1.setBorderBetween(Borders.SINGLE);

    p1.setVerticalAlignment(TextAlignment.TOP);

    XWPFRun r1 = p1.createRun();
    r1.setBold(true);
    r1.setText("The quick brown fox");
    r1.setBold(true);
    r1.setFontFamily("Courier");
    r1.setUnderline(UnderlinePatterns.DOT_DOT_DASH);
    r1.setTextPosition(100);

    XWPFParagraph p2 = doc.createParagraph();
    p2.setAlignment(ParagraphAlignment.RIGHT);

    //BORDERS
    p2.setBorderBottom(Borders.DOUBLE);
    p2.setBorderTop(Borders.DOUBLE);
    p2.setBorderRight(Borders.DOUBLE);
    p2.setBorderLeft(Borders.DOUBLE);
    p2.setBorderBetween(Borders.SINGLE);

    XWPFRun r2 = p2.createRun();
    r2.setText("jumped over the lazy dog");
    //  r2.setStrikeThrough(true);
    r2.setFontSize(20);

    XWPFRun r3 = p2.createRun();
    r3.setText("and went away");
    //  r3.setStrikeThrough(true);
    r3.setFontSize(20);
    r3.setSubscript(VerticalAlign.SUPERSCRIPT);

    XWPFParagraph p3 = doc.createParagraph();
    // p3.setWordWrapped(true);
    p3.setPageBreak(true);

    //p3.setAlignment(ParagraphAlignment.DISTRIBUTE);
    p3.setAlignment(ParagraphAlignment.BOTH);
    // p3.setSpacingBetween(15, LineSpacingRule.EXACT);

    p3.setIndentationFirstLine(600);

    XWPFRun r4 = p3.createRun();
    r4.setTextPosition(20);
    r4.setText("To be, or not to be: that is the question: " + "Whether 'tis nobler in the mind to suffer "
            + "The slings and arrows of outrageous fortune, " + "Or to take arms against a sea of troubles, "
            + "And by opposing end them? To die: to sleep; ");
    r4.addBreak(BreakType.PAGE);
    r4.setText("No more; and by a sleep to say we end " + "The heart-ache and the thousand natural shocks "
            + "That flesh is heir to, 'tis a consummation " + "Devoutly to be wish'd. To die, to sleep; "
            + "To sleep: perchance to dream: ay, there's the rub; " + ".......");
    r4.setItalic(true);
    //This would imply that this break shall be treated as a simple line break, and break the line after that word:

    XWPFRun r5 = p3.createRun();
    r5.setTextPosition(-10);
    r5.setText("For in that sleep of death what dreams may come");
    r5.addCarriageReturn();
    r5.setText("When we have shuffled off this mortal coil," + "Must give us pause: there's the respect"
            + "That makes calamity of so long life;");
    r5.addBreak();
    r5.setText("For who would bear the whips and scorns of time,"
            + "The oppressor's wrong, the proud man's contumely,");

    r5.addBreak(BreakClear.ALL);
    r5.setText("The pangs of despised love, the law's delay," + "The insolence of office and the spurns"
            + ".......");

    FileOutputStream out = new FileOutputStream("simple.docx");
    doc.write(out);
    out.close();
    // out.close ();
}

From source file:patientmanagerv1.HomeController.java

public void writeEvalToDocX(boolean customPath, String path) {
    FileOutputStream outstream;/*  w w w  .  j  ava 2  s  .c om*/

    try {
        if (customPath == false) {
            outstream = new FileOutputStream(installationPath + "/userdata/" + firstName + lastName + dob + "/"
                    + firstName + lastName + dob + "psychiatricevaluation.docx");
        } else {
            outstream = new FileOutputStream(path + ".docx");
        }

        XWPFDocument doc = new XWPFDocument();
        //due to the redirection of these e's, even physically, your str will begin to deteriorate. Corpse-like, in other words.

        /*XWPFParagraph para = doc.createParagraph();
        para.setAlignment(ParagraphAlignment.CENTER);
        XWPFRun paraRun = para.createRun();
        paraRun.setBold(true);
        paraRun.setFontSize(12);
        //paraRun.setFontSize(16);
        paraRun.setText("Hello World");*/

        XWPFParagraph header = doc.createParagraph(); //Paragraph
        XWPFRun headerLabel = header.createRun(); //Where the text will be written from
        header.setAlignment(ParagraphAlignment.CENTER);
        headerLabel.setFontFamily("16");
        headerLabel.setBold(true);
        headerLabel.setText("Advanced Psychiatric Associates");
        headerLabel.addBreak();
        headerLabel.setText("Psychiatric Evaluation");
        headerLabel.addBreak();

        XWPFParagraph p = doc.createParagraph(); //Paragraph
        XWPFRun run = p.createRun(); //Where the text will be written from
        XWPFRun run2 = p.createRun();
        XWPFRun run3 = p.createRun();
        XWPFRun run4 = p.createRun();
        XWPFRun run5 = p.createRun();
        XWPFRun run6 = p.createRun();
        XWPFRun run7 = p.createRun();
        XWPFRun run8 = p.createRun();
        XWPFRun run9 = p.createRun();
        XWPFRun run10 = p.createRun();
        XWPFRun run11 = p.createRun();
        XWPFRun run12 = p.createRun();
        XWPFRun run13 = p.createRun();
        XWPFRun run14 = p.createRun();
        XWPFRun run15 = p.createRun();
        XWPFRun run16 = p.createRun();
        XWPFRun run17 = p.createRun();
        XWPFRun run18 = p.createRun();
        XWPFRun anEdit1 = p.createRun();
        XWPFRun run19 = p.createRun();
        XWPFRun run20 = p.createRun();
        XWPFRun run21 = p.createRun();
        XWPFRun run22 = p.createRun();
        XWPFRun run23 = p.createRun();
        XWPFRun run24 = p.createRun();
        XWPFRun run25 = p.createRun();
        XWPFRun run26 = p.createRun();
        XWPFRun run27 = p.createRun();
        XWPFRun run28 = p.createRun();
        XWPFRun run29 = p.createRun();
        XWPFRun run30 = p.createRun();
        XWPFRun run31 = p.createRun(); //Where the text will be written from
        XWPFRun run32 = p.createRun();
        XWPFRun run33 = p.createRun();
        XWPFRun run34 = p.createRun();
        XWPFRun run35 = p.createRun();
        XWPFRun run36 = p.createRun();
        XWPFRun run37 = p.createRun();
        XWPFRun run38 = p.createRun();
        XWPFRun run39 = p.createRun();
        XWPFRun run40 = p.createRun();
        XWPFRun run41 = p.createRun();
        XWPFRun run42 = p.createRun();
        XWPFRun run42Bold = p.createRun();
        XWPFRun runPre43 = p.createRun();
        XWPFRun run43 = p.createRun();
        XWPFRun run44 = p.createRun();
        XWPFRun run45 = p.createRun();
        XWPFRun run46 = p.createRun();
        XWPFRun run47 = p.createRun();
        XWPFRun run48 = p.createRun();
        XWPFRun run49 = p.createRun();
        XWPFRun run50 = p.createRun();
        XWPFRun run51 = p.createRun();
        XWPFRun run52 = p.createRun();
        XWPFRun run53 = p.createRun();
        XWPFRun run54 = p.createRun();
        XWPFRun run55 = p.createRun();
        XWPFRun run56 = p.createRun();
        XWPFRun run57 = p.createRun();
        XWPFRun run58 = p.createRun();
        XWPFRun run59 = p.createRun();
        XWPFRun run60 = p.createRun();

        run.setBold(true);
        run2.setBold(false);
        run3.setBold(true);
        run4.setBold(false);
        run5.setBold(true);
        run6.setBold(false);
        run7.setBold(true);
        run8.setBold(false);
        run9.setBold(true);
        run10.setBold(false);
        run11.setBold(true);
        run12.setBold(false);
        run13.setBold(true);
        run14.setBold(false);
        run15.setBold(true);
        run16.setBold(false);
        run17.setBold(true);
        run18.setBold(false);
        run19.setBold(true);
        run20.setBold(false);
        run21.setBold(true);
        run22.setBold(false);
        run23.setBold(true);
        run24.setBold(false);
        run25.setBold(true);
        run26.setBold(false);
        run27.setBold(true);
        run28.setBold(false);
        run29.setBold(true);
        run30.setBold(false);

        /*
            @FXML
        AnchorPane ap;
        @FXML
        TextField first, last, ageText, dobText;
        @FXML
        TextField ethnicityothertext;
        @FXML
        RadioButton male, female;
        @FXML
        RadioButton single, engaged, married, seperated, divorced, commonlawspouse, cohabiting; 
        @FXML
        CheckBox africanamerican, nativeamerican, hispanic, asian, caucasian, ethnicityother, ocd, bipolardisorder, socialphobia, panicdisorder, eatingdisorder, majordepressivedisorder, psychosis;
        @FXML
        RadioButton insurance, internet, pcp, cps, therapist, referredbyother;
        @FXML
        TextField referredbytherapisttext, referredbyothertext, reasonforreferralbox;
        @FXML
        Button sign, saveButton;
        @FXML
        Label signature;
        @FXML
        CheckBox patient, spouse, mother, father, othersourceofinformation, emp, unemp, disabilityincome;
        @FXML
        TextField othersourceofinformationbox, otherreliabilityofinformationbox;
        @FXML
        RadioButton good, fair, vague, minimizing, otherreliabilityofinformation, sano, sayes, physicalabuseno, physicalabuseyes, sexualabuseno, sexualabuseyes, violentaggressivebehaviorsno, violentaggressivebehaviorsyes, selfinjuriousbehaviorsno, selfinjuriousbehaviorsyes;
        @FXML
        TextArea historyofpresentillness, currentmedications, pastpsychiatrichistory, pasthistoryoftext, historyofmedicationtrialsinthepasttable, historyofmedicationtrialsinthepastcomments, substanceusehistory;
        @FXML
        ListView listOfProgressReports;
        @FXML
        CheckBox significantwithdrawals, dts, withdrawalseizures, historyofdetox, outpatient, inpatient, na, aa, substancetreatmentprogram, nkda, environmental;
        @FXML
        TextField inpatientbox, parents, siblings, children, education, allergiesdescriptionbox;
        @FXML
        TextArea socialhistorygeneral, familyhistoryofmentalillness, legalhistory, pastmedicalhistory;
        @FXML
        RadioButton fhomiNO, fhomiYES, eyecontactgood, eyecontactpoor, eyecontactvariable;
        @FXML
        TextField appearanceotherbox, attitudeotherbox, motoractivityotherbox;
        @FXML
        CheckBox wellgroomed, casual, disheveled, bizarre, inappropriate, appearanceother, cooperative, guarded, suspicious, withdrawn, uncooperative, hostile, defensive, attitudeother;
        @FXML
        CheckBox normal, agitated, motorretardation, hyperactive, catatonia, tremorstics, motoractivityother;
        @FXML
        CheckBox appropriate, labile, expansive, constricted, affecthappy, affectsad, blunted, flat, masking, affectnormalrange;
        @FXML
        CheckBox euthymic, depressed, dysphoric, anxious, euphoric, angry, irritable, moodsad;
        @FXML
        CheckBox normal2, delayed, soft, loud, slurred, excessive, pressured, perseverating, rapid, rambling, incoherent, disorganized, decreasedproductivity;
        @FXML
        CheckBox intact, circumstantial, loa, tangential, foi, logicalgoaldirected, thoughtblocking, ruminating, racingthoughts, thoughtinsertionwithdrawalbroadcast;
        */

        //alternative solution: so I guess, a seperate run for each form element, followed by an if statement
        //run is created here if(divorced.isSelected == "true"){run.setBold(true); run.setText("divorced");} else {run.setBold(false); run.setText("divorced")}
        //single, engaged, married, seperated, divorced, commonlawspouse, cohabiting; 

        //greater: MM, gbits, (much) lesser: id'ing
        run.setText("Patient Name: ");
        //doc.write(outstream);
        //outstream.close();
        // doc.createParagraph().createRun().setBold(true);

        //run.setBold(false);
        //run.setText("Ciel Phantomhive");

        run2.setText(first.getText() + " " + last.getText());
        run3.setText("              Age: ");
        //run2.setTextPosition(run2.getTextPosition());
        run4.setText(ageText.getText());
        run5.setText("                              DOB: ");
        run6.setText(dobText.getText());
        run6.addBreak();
        run6.addBreak();

        run7.setBold(false);
        run7.setText("Marital Status: ");
        //single, engaged, married, seperated, divorced, commonlawspouse, cohabiting;             
        if (single.isSelected()) {
            run7.setText("     Single");
        }
        if (engaged.isSelected()) {
            run7.setText("     Engaged");
        }
        if (married.isSelected()) {
            run7.setText("     Married");
        }
        if (seperated.isSelected()) {
            run7.setText("     Seperated");
        }
        if (divorced.isSelected()) {
            run7.setText("     Divorced");
        }
        if (commonlawspouse.isSelected()) {
            run7.setText("     Common Law Spouse");
        }
        if (cohabiting.isSelected()) {
            run7.setText("     Cohabiting");
        }
        run7.addBreak();
        run7.setText("Ethnicity: ");
        //africanamerican, nativeamerican, hispanic, asian, caucasian, ethnicityother, ocd, bipolardisorder, socialphobia, panicdisorder, eatingdisorder, majordepressivedisorder, psychosis;
        if (africanamerican.isSelected()) {
            run7.setText("     African American");
        }
        if (nativeamerican.isSelected()) {
            run7.setText("      Native American");
        }
        if (hispanic.isSelected()) {
            run7.setText("     Hispanic");
        }
        if (asian.isSelected()) {
            run7.setText("     Asian");
        }
        if (caucasian.isSelected()) {
            run7.setText("     Caucasian");
        }
        if (ethnicityother.isSelected()) {
            run7.setText("     " + ethnicityothertext.getText());
        }

        run7.addBreak();
        run7.setText("Sex: ");
        if (male.isSelected()) {
            run7.setText("     Male");
        }
        if (female.isSelected()) {
            run7.setText("      Female");
        }

        run7.addBreak();
        run7.setText("Referred By: ");
        //insurance, internet, pcp, cps, therapist, referredbyother
        if (insurance.isSelected()) {
            run7.setText("     Insurance");
        }
        if (internet.isSelected()) {
            run7.setText("     Internet");
        }
        if (pcp.isSelected()) {
            run7.setText("     PCP");
        }
        if (cps.isSelected()) {
            run7.setText("     CPS");
        }
        if (therapist.isSelected()) {
            run7.setText("     therapist- " + referredbytherapisttext.getText());
        }
        if (referredbyother.isSelected()) {
            run7.setText("     " + referredbyothertext.getText());
        }

        run7.addBreak();
        run7.setText("Reason for Referral: ");
        if (reasonforreferralpsychiatricevaluation.isSelected()) {
            run7.setText("     Psychiatric Evaluation");
        }
        if (reasonforreferralmedicationmanagement.isSelected()) {
            run7.setText("      Medication Management");
        }

        run7.addBreak();
        run7.setText("Source of Information: ");
        //insurance, internet, pcp, cps, therapist, referredbyother
        if (patient.isSelected()) {
            run7.setText("     Patient");
        }
        if (spouse.isSelected()) {
            run7.setText("     Spouse");
        }
        if (mother.isSelected()) {
            run7.setText("     Mother");
        }
        if (father.isSelected()) {
            run7.setText("     Father");
        }
        if (othersourceofinformation.isSelected()) {
            run7.setText("     " + othersourceofinformationbox.getText());
        }

        run7.addBreak();
        run7.setText("Reliability of Information: ");
        //insurance, internet, pcp, cps, therapist, referredbyother
        if (good.isSelected()) {
            run7.setText("     Good");
        }
        if (fair.isSelected()) {
            run7.setText("     Fair");
        }
        if (vague.isSelected()) {
            run7.setText("     Vague");
        }
        if (minimizing.isSelected()) {
            run7.setText("     Minimizing");
        }
        if (otherreliabilityofinformation.isSelected()) {
            run7.setText("     " + otherreliabilityofinformationbox.getText());
        }

        run7.setText(" (Options: good, fair, vague, minimizing, other)");
        run7.addBreak();
        run7.addBreak();
        run8.setBold(true);
        run8.setUnderline(UnderlinePatterns.SINGLE);
        run8.setText("History of Present Illness");
        run8.addBreak();
        run9.setBold(false);
        run9.setText(historyofpresentillness.getText());
        run9.addBreak();
        run9.addBreak();
        run10.setBold(true);
        run10.setText("Patient denied signs or symptoms of: ");
        run11.setBold(false);

        //ocd, bipolardisorder, socialphobia, panicdisorder, eatingdisorder, majordepressivedisorder, psychosis

        if (ocd.isSelected() == true) {
            run11.setText("     OCD");
        }
        if (bipolardisorder.isSelected() == true) {
            run11.setText("     Bipolar Disorder");
        }
        if (socialphobia.isSelected() == true) {
            run11.setText("     Social Phobia");
        }
        if (panicdisorder.isSelected() == true) {
            run11.setText("     Panic Disorder");
        }
        if (eatingdisorder.isSelected() == true) {
            run11.setText("     Eating Disorder");
        }
        if (majordepressivedisorder.isSelected() == true) {
            run11.setText("     Major Depressive Disorder");
        }
        if (psychosis.isSelected() == true) {
            run11.setText("     Psychosis");
        }
        run11.addBreak();
        run11.addBreak();

        run12.setUnderline(UnderlinePatterns.SINGLE);
        run12.setBold(true);
        run12.setText("Current Medications (including over-the-counter medications and vitamins)");
        run12.addBreak();
        run13.setBold(false);
        run13.setText(currentmedications.getText());

        run13.addBreak();
        run13.addBreak();

        run14.setUnderline(UnderlinePatterns.SINGLE);
        run14.setBold(true);
        run14.setText("Past Psychiatric History");
        run14.addBreak();
        run15.setBold(false);
        run15.setText(pastpsychiatrichistory.getText());
        run15.addBreak();
        run15.addBreak();

        run16.setBold(true);
        run16.setText("Past History Of");
        run16.addBreak();

        run17.setBold(false);
        run17.setText("Suicide Attempts: ");

        //past history of
        if (sano.isSelected() == true) {
            run17.setText("No");
        } else if (sayes.isSelected() == true) {
            run17.setText("Yes");
        }
        run17.addBreak();
        if (physicalabuseno.isSelected() == true) {
            run17.setText("Physical Abuse: No");
        } else if (physicalabuseyes.isSelected() == true) {
            run17.setText("Physical Abuse: Yes");
        }
        run17.addBreak();
        if (sexualabuseno.isSelected() == true) {
            run17.setText("Sexual Abuse: No");
        } else if (sexualabuseyes.isSelected() == true) {
            run17.setText("Sexual Abuse: Yes");
        }
        run17.addBreak();
        if (violentaggressivebehaviorsno.isSelected() == true) {
            run17.setText("Violent/Aggressive Behaviors: No");
        } else if (violentaggressivebehaviorsyes.isSelected() == true) {
            run17.setText("Violent/Aggressive Behaviors: Yes");
        }
        run17.addBreak();
        if (selfinjuriousbehaviorsno.isSelected() == true) {
            run17.setText("Self-Injurious Behaviors: No");
        } else if (selfinjuriousbehaviorsyes.isSelected() == true) {
            run17.setText("Self-Injurious Behaviors: Yes");
        }
        run17.addBreak();
        run17.setText(pasthistoryoftext.getText());
        run17.addBreak();
        run17.addBreak();

        run18.setUnderline(UnderlinePatterns.SINGLE);
        run18.setBold(true);
        run18.setText("History of Medication Trials in the Past");
        run18.addBreak();
        anEdit1.setBold(true);
        anEdit1.setText(
                "Medication                                   Dosage                                 Duration");
        anEdit1.addBreak();

        run19.setBold(false);

        String fulltext = historyofmedicationtrialsinthepasttable.getText();
        String[] lines = fulltext.split("\n");

        for (int i = 0; i < lines.length; i++) {
            String[] modifyThis = lines[i].split("    ");
            for (int j = 0; j < modifyThis.length; j++) {
                run19.setText(modifyThis[j].trim() + "                ");
            }

            //run19.setText(lines[i]);

            run19.addBreak();
        }

        //run19.setText(lines[0]);
        run19.addBreak();
        run19.addBreak();
        run19.setText("Comments: " + historyofmedicationtrialsinthepastcomments.getText());
        run19.addBreak();
        run19.addBreak();

        run20.setBold(true);
        run20.setText("Substance Use History:");
        run20.addBreak();

        run21.setBold(false);
        run21.setText(substanceusehistory.getText());
        run21.addBreak();
        //run21.setText("Denies history of: ");

        String denies = "";

        if (significantwithdrawals.isSelected() == true) {
            denies = denies + "Significant Withdrawals, ";
        }
        if (dts.isSelected() == true) {
            denies = denies + "DTS, ";
        }
        if (withdrawalseizures.isSelected() == true) {
            denies = denies + "Withdrawal Seizures, ";
        }
        if (historyofdetox.isSelected() == true) {
            denies = denies + "History Of Detox, ";
        }
        if (outpatient.isSelected() == true) {
            denies = denies + "Outpatient, ";
        }
        if (inpatient.isSelected() == true) {
            denies = denies + "Inpatient, ";
        }
        if (na.isSelected() == true) {
            denies = denies + "NA, ";
        }
        if (aa.isSelected() == true) {
            denies = denies + "AA, ";
        }
        if (substancetreatmentprogram.isSelected() == true) {
            denies = denies + "Substance Treatment Program, ";
        }

        if (denies.length() > 2) {
            denies = denies.substring(0, denies.length() - 2);
            denies = denies.trim();
        }

        //Fandom Follower- anonomously discuss your fandom
        //select/create/add a new fandom group to the list/search
        //browse fanart, view fandom updates, add materials to your local board
        run21.setText("Denies History Of: " + denies);
        run21.addBreak();
        run21.addBreak();

        run22.setUnderline(UnderlinePatterns.SINGLE);
        run22.setBold(true);
        run22.setText("Social History: ");
        run22.addBreak();
        //y the fm, m homu cov e's, ah chained, ank snk
        //
        //ASP.NET in visual studio, eclipse, netbeans

        //dk y lol
        run23.setBold(false);
        run23.setText(socialhistorygeneral.getText());
        run23.addBreak();
        run23.addBreak();
        run23.setText("Parents: " + parents.getText());
        run23.addBreak();
        run23.setText("Siblings: " + siblings.getText());
        run23.addBreak();
        run23.setText("Children: " + children.getText());
        run23.addBreak();

        String faHist;
        if (fhomiNO.isSelected() == true) {
            faHist = "No";
        } else {
            faHist = "Yes";
        }

        run23.setText("Family History of Mental Illness? " + faHist);
        run23.addBreak();
        run23.setText(familyhistoryofmentalillness.getText());
        run23.addBreak();
        run23.addBreak();
        run23.setText(education.getText());
        run23.addBreak();

        String e = "";
        if (emp.isSelected() == true) {
            e = e + "Employed, ";
        }
        if (unemp.isSelected() == true) {
            e = e + "Unemployed, ";
        }
        if (disabilityincome.isSelected() == true) {
            e = e + "Disability Income, ";
        }

        if (e.length() > 2) {
            e = e.substring(0, e.length() - 2);
            e = e.trim();
        }

        run23.setText("Employment: " + e);
        run23.addBreak();

        run23.setText(legalhistory.getText());
        run23.addBreak();
        run23.addBreak();

        run24.setUnderline(UnderlinePatterns.SINGLE);
        run24.setBold(true);
        run24.setText("Past Medical History");
        run24.addBreak();
        run25.setBold(false);
        run25.setText(pastmedicalhistory.getText());
        run25.addBreak();
        run26.setBold(true);
        run26.setText("Allergies: ");
        String allergies = " ";

        if (nkda.isSelected() == true) {
            allergies = allergies + "nkda, ";
        }
        if (environmental.isSelected() == true) {
            allergies = allergies + "environmental, ";
        }

        if (allergies.length() > 2) {
            allergies = allergies.substring(0, allergies.length() - 2);
            allergies = allergies.trim();
        }

        run27.setBold(false);
        run27.setText(allergies);
        run27.addBreak();
        run27.setText(allergiesdescriptionbox.getText());
        run27.addBreak();
        run27.addBreak();

        run28.setUnderline(UnderlinePatterns.SINGLE);
        run28.setBold(true);
        run28.setText("Mental Status Examination:");
        run29.addBreak();
        run30.setBold(false);

        String appearance = " ";

        if (wellgroomed.isSelected() == true) {
            appearance = appearance + "Well Groomed, ";
        }
        if (casual.isSelected() == true) {
            appearance = appearance + "Casual, ";
        }
        if (disheveled.isSelected() == true) {
            appearance = appearance + "Disheveled, ";
        }
        if (bizarre.isSelected() == true) {
            appearance = appearance + "Bizarre, ";
        }
        if (inappropriate.isSelected() == true) {
            appearance = appearance + "Inappropriate,";
        }
        if (appearanceother.isSelected() == true) {
            appearance = appearance + "Other: ";
        }

        if (appearance.length() > 2) {
            appearance = appearance.substring(0, appearance.length() - 2);
            appearance = appearance.trim();
        }

        run30.setText("Appearance: " + appearance);
        if (appearanceother.isSelected()) {
            run30.setText(" - " + appearanceotherbox.getText());
        }

        run30.addBreak();

        String eC = "blah";

        if (eyecontactgood.isSelected() == true) {
            eC = "Good";
        }
        if (eyecontactpoor.isSelected() == true) {
            eC = "Poor";
        }
        if (eyecontactvariable.isSelected() == true) {
            eC = "Variable";
        }

        run30.setText("Eye Contact: " + eC);
        run30.addBreak();

        String attitude = " ";

        if (cooperative.isSelected() == true) {
            attitude = attitude + "Cooperative, ";
        }
        if (guarded.isSelected() == true) {
            attitude = attitude + "Guarded, ";
        }
        if (suspicious.isSelected() == true) {
            attitude = attitude + "Suspicious, ";
        }
        if (withdrawn.isSelected() == true) {
            attitude = attitude + "Withdrawn, ";
        }
        if (uncooperative.isSelected() == true) {
            attitude = attitude + "Uncooperative, ";
        }
        if (hostile.isSelected() == true) {
            attitude = attitude + "Hostile, ";
        }
        if (defensive.isSelected() == true) {
            attitude = attitude + "Defensive, ";
        }
        if (attitudeother.isSelected() == true) {
            attitude = attitude + "Other: ";
        }

        if (attitude.length() > 2) {
            attitude = attitude.substring(0, attitude.length() - 2);
            attitude = attitude.trim();
        }

        run30.setText("Attitude: " + attitude);
        if (attitudeother.isSelected()) {
            run30.setText(" - " + attitudeotherbox.getText());
        }
        run30.addBreak();

        String motoractivity = " ";

        if (normal.isSelected() == true) {
            motoractivity = motoractivity + "Normal, ";
        }
        if (agitated.isSelected() == true) {
            motoractivity = motoractivity + "Agitated, ";
        }
        if (motorretardation.isSelected() == true) {
            motoractivity = motoractivity + "Motor Retardation, ";
        }
        if (hyperactive.isSelected() == true) {
            motoractivity = motoractivity + "Hyperactive, ";
        }
        if (catatonia.isSelected() == true) {
            motoractivity = motoractivity + "Catatonia, ";
        }
        if (tremorstics.isSelected() == true) {
            motoractivity = motoractivity + "Tremors/Tics, ";
        }
        if (motoractivityother.isSelected() == true) {
            motoractivity = motoractivity + "Other: ";
        }

        if (motoractivity.length() > 2) {
            motoractivity = motoractivity.substring(0, motoractivity.length() - 2);
            motoractivity = motoractivity.trim();
        }

        run30.setText("Motor Activity: " + motoractivity);
        if (motoractivityother.isSelected()) {
            run30.setText(" - " + motoractivityotherbox.getText());
        }

        run30.addBreak();

        String affect = " ";

        if (appropriate.isSelected() == true) {
            affect = affect + "Appropriate, ";
        }
        if (labile.isSelected() == true) {
            affect = affect + "Labile, ";
        }
        if (expansive.isSelected() == true) {
            affect = affect + "Expansive, ";
        }
        if (constricted.isSelected() == true) {
            affect = affect + "Constricted, ";
        }
        if (affecthappy.isSelected() == true) {
            affect = affect + "Happy, ";
        }
        if (affectsad.isSelected() == true) {
            affect = affect + "Sad, ";
        }
        if (blunted.isSelected() == true) {
            affect = affect + "Blunted, ";
        }
        if (flat.isSelected() == true) {
            affect = affect + "Flat, ";
        }
        if (masking.isSelected() == true) {
            affect = affect + "Masking, ";
        }
        if (affectnormalrange.isSelected() == true) {
            affect = affect + "Normal Range, ";
        }

        if (affect.length() > 2) {
            affect = affect.substring(0, affect.length() - 2);
            affect = affect.trim();
        }

        run30.setText("Affect: " + affect);
        run30.addBreak();

        String mood = " ";

        if (euthymic.isSelected() == true) {
            mood = mood + "Euthymic, ";
        }
        if (depressed.isSelected() == true) {
            mood = mood + "Depressed, ";
        }
        if (dysphoric.isSelected() == true) {
            mood = mood + "Dysphoric, ";
        }
        if (anxious.isSelected() == true) {
            mood = mood + "Anxious, ";
        }
        if (euphoric.isSelected() == true) {
            mood = mood + "Euphoric, ";
        }
        if (angry.isSelected() == true) {
            mood = mood + "Angry, ";
        }
        if (irritable.isSelected() == true) {
            mood = mood + "Irritable, ";
        }
        if (moodsad.isSelected() == true) {
            mood = mood + "Sad, ";
        }

        if (mood.length() > 2) {
            mood = mood.substring(0, mood.length() - 2);
            mood = mood.trim();
        }

        run30.setText("Mood: " + mood);
        run30.addBreak();

        String speech = " ";

        if (normal2.isSelected() == true) {
            speech = speech + "Normal, ";
        }
        if (delayed.isSelected() == true) {
            speech = speech + "Delayed, ";
        }
        if (soft.isSelected() == true) {
            speech = speech + "Soft, ";
        }
        if (loud.isSelected() == true) {
            speech = speech + "Loud, ";
        }
        if (slurred.isSelected() == true) {
            speech = speech + "Slurred, ";
        }
        if (excessive.isSelected() == true) {
            speech = speech + "Excessive, ";
        }
        if (pressured.isSelected() == true) {
            speech = speech + "Pressured, ";
        }
        if (perseverating.isSelected() == true) {
            speech = speech + "Perseverating, ";
        }
        if (rapid.isSelected() == true) {
            speech = speech + "Rapid, ";
        }
        if (rambling.isSelected() == true) {
            speech = speech + "Rambling, ";
        }
        if (incoherent.isSelected() == true) {
            speech = speech + "Incoherent, ";
        }
        if (disorganized.isSelected() == true) {
            speech = speech + "Disorganized, ";
        }
        if (decreasedproductivity.isSelected() == true) {
            speech = speech + "Decreased Productivity, ";
        }

        if (speech.length() > 2) {
            speech = speech.substring(0, speech.length() - 2);
            speech = speech.trim();
        }

        run30.setText("Speech: " + speech);
        run30.addBreak();

        String per = " ";

        if (visualhallucinations.isSelected() == true) {
            per = per + "Visual Hallucinations, ";
        }
        if (auditoryhallucinations.isSelected() == true) {
            per = per + "Auditory Hallucinations, ";
        }
        if (depersonalization.isSelected() == true) {
            per = per + "Depersonalization, ";
        }
        if (derealization.isSelected() == true) {
            per = per + "Derealization, ";
        }
        if (commandah.isSelected() == true) {
            per = per + "Command AH, ";
        }
        if (delusions2.isSelected() == true) {
            per = per + "Delusions, ";
        }
        if (illusions.isSelected() == true) {
            per = per + "Illusions, ";
        }
        if (perceptionnoimpairment.isSelected() == true) {
            per = per + "No Impairment, ";
        }

        if (per.length() > 2) {
            per = per.substring(0, per.length() - 2);
            per = per.trim();
        }

        run30.setText("Perception: " + per);
        run30.addBreak();

        String thoughtProcess = " ";

        if (intact.isSelected() == true) {
            thoughtProcess = thoughtProcess + "Intact, ";
        }
        if (circumstantial.isSelected() == true) {
            thoughtProcess = thoughtProcess + "Circumstantial, ";
        }
        if (loa.isSelected() == true) {
            thoughtProcess = thoughtProcess + "LOA, ";
        }
        if (tangential.isSelected() == true) {
            thoughtProcess = thoughtProcess + "Tangential, ";
        }
        if (foi.isSelected() == true) {
            thoughtProcess = thoughtProcess + "FOI, ";
        }
        if (logicalgoaldirected.isSelected() == true) {
            thoughtProcess = thoughtProcess + "Logical Goal Directed, ";
        }
        if (thoughtblocking.isSelected() == true) {
            thoughtProcess = thoughtProcess + "Thought Blocking, ";
        }
        if (ruminating.isSelected() == true) {
            thoughtProcess = thoughtProcess + "Ruminating, ";
        }
        if (racingthoughts.isSelected() == true) {
            thoughtProcess = thoughtProcess + "Racing Thoughts, ";
        }
        if (thoughtinsertionwithdrawalbroadcast.isSelected() == true) {
            thoughtProcess = thoughtProcess + "Thought Insertion/Withdrawal/Broadcast, ";
        }

        if (thoughtProcess.length() > 2) {
            thoughtProcess = thoughtProcess.substring(0, thoughtProcess.length() - 2);
            thoughtProcess = thoughtProcess.trim();
        }

        run30.setText("Thought Process: " + thoughtProcess);
        run30.addBreak();

        String thoughtContent = "";
        //hummus/tahini, "steak", p seeds/walnuts, k p + sm papr; curry, hazelnut meal + a fig + 1tsp pb + 1tsp white flour + a few drops of maple syrup
        //get some (pepper) A1!!!
        //bbq sauce
        if (logicalcoherent.isSelected() == true) {
            thoughtContent = thoughtContent + "Logical Coherent, ";
        }
        if (povertyofcontent.isSelected() == true) {
            thoughtContent = thoughtContent + "Poverty Of Content, ";
        }
        if (ideasofreference.isSelected() == true) {
            thoughtContent = thoughtContent + "Ideas Of Reference, ";
        }
        if (obsessions.isSelected() == true) {
            thoughtContent = thoughtContent + "Obsessions, ";
        }
        if (phobias.isSelected() == true) {
            thoughtContent = thoughtContent + "Phobias, ";
        }
        if (paranoidideation.isSelected() == true) {
            thoughtContent = thoughtContent + "Paranoid Ideation, ";
        }
        if (delusions.isSelected() == true) {
            thoughtContent = thoughtContent + "Delusions, ";
        }

        if (thoughtContent.length() > 2) {
            thoughtContent = thoughtContent.substring(0, thoughtContent.length() - 2);
            thoughtContent = thoughtContent.trim();
        }

        run30.setText("Thought Content: " + thoughtContent);
        if (delusions.isSelected()) {
            run30.setText(" - " + delusionsbox.getText());
        }
        run30.addBreak();

        String suicidality = " ";

        if (suicidalitydenied.isSelected() == true) {
            suicidality = suicidality + "Suicidality Denied, ";
        }
        if (suicidalityideation.isSelected() == true) {
            suicidality = suicidality + "Suicidality Ideation, ";
        }
        if (suicidalityintent.isSelected() == true) {
            suicidality = suicidality + "Suicidality Intent, ";
        }
        if (suicidalityplan.isSelected() == true) {
            suicidality = suicidality + "Suicidality Plan: ";
        }

        if (suicidality.length() > 2) {
            suicidality = suicidality.substring(0, suicidality.length() - 2);
            suicidality = suicidality.trim();
        }

        run30.setText("Suicidality: " + suicidality);
        if (suicidalityplan.isSelected()) {
            run30.setText(" - " + suicidalityplanbox.getText());
        }
        run30.addBreak();

        String homicidality = " ";

        if (homicidalitydenied.isSelected() == true) {
            homicidality = homicidality + "Homicidality Denied, ";
        }
        if (homicidalityideation.isSelected() == true) {
            homicidality = homicidality + "Homicidality Ideation, ";
        }
        if (homicidalityintent.isSelected() == true) {
            homicidality = homicidality + "Homicidality Intent, ";
        }
        if (homicidalityplan.isSelected() == true) {
            homicidality = homicidality + "Homicidality Plan: ";
        }

        if (homicidality.length() > 2) {
            homicidality = homicidality.substring(0, homicidality.length() - 2);
            homicidality = homicidality.trim();
        }

        run30.setText("Homicidality: " + homicidality);
        if (homicidalityplan.isSelected()) {
            run30.setText(" - " + homicidalityplanbox.getText());
        }
        run30.addBreak();
        if (suicidalityhomicidalitycomments.getText().length() >= 2) {
            run30.setText(" \t Comments - " + suicidalityhomicidalitycomments.getText());
        }
        run30.addBreak();

        String orientation = " ";

        if (fullyoriented.isSelected() == true) {
            orientation = orientation + "Fully Oriented, ";
        }
        if (disoriented.isSelected() == true) {
            orientation = orientation + "Disoriented: ";
        }
        if (person.isSelected() == true) {
            orientation = orientation + "Person, ";
        }
        if (place.isSelected() == true) {
            orientation = orientation + "Place, ";
        }
        if (time.isSelected() == true) {
            orientation = orientation + "Time, ";
        }

        if (orientation.length() > 2) {
            orientation = orientation.substring(0, orientation.length() - 2);
            orientation = orientation.trim();
        }

        run30.setText("Orientation: " + orientation);
        run30.addBreak();

        String stm = " ";

        //shorttermmemorywithinnormallimits, shorttermmermorydeficits, longtermmemorywithinnormallimits,longtermmemorydeficits, shorttermmemorydeficitsbox, longtermmemorydeficitsbox
        if (shorttermmemorywithinnormallimits.isSelected() == true) {
            stm = stm + "Within Normal Limits, ";
        }
        if (shorttermmemorydeficits.isSelected() == true) {
            stm = stm + "Deficits, ";
        }

        if (stm.length() > 2) {
            stm = stm.substring(0, stm.length() - 2);
            stm = stm.trim();
        }

        run30.setText("Short Term Memory: " + stm);
        if (shorttermmemorydeficits.isSelected() == true) {
            run30.setText(" - " + shorttermmemorydeficitsbox.getText());
        }
        run30.addBreak();

        String ltm = " ";

        if (longtermmemorywithinnormallimits.isSelected() == true) {
            ltm = ltm + "Within Normal Limits, ";
        }
        if (longtermmemorydeficits.isSelected() == true) {
            ltm = ltm + "Deficits, ";
        }

        if (ltm.length() > 2) {
            ltm = ltm.substring(0, ltm.length() - 2);
            ltm = ltm.trim();
        }

        run30.setText("Long Term Memory: " + ltm);
        if (longtermmemorydeficits.isSelected() == true) {
            run30.setText(" - " + longtermmemorydeficitsbox.getText());
        }
        run30.addBreak();

        String gfok = " ";

        if (generalfundofknowledgewithinnormallimits.isSelected() == true) {
            gfok = gfok + "Within Normal Limits, ";
        }
        if (generalfundofknowledgedeficits.isSelected() == true) {
            gfok = gfok + "Deficits, ";
        }

        if (gfok.length() > 2) {
            gfok = gfok.substring(0, gfok.length() - 2);
            gfok = gfok.trim();
        }

        run30.setText("General Fund of Knowledge: " + gfok);
        if (generalfundofknowledgedeficits.isSelected() == true) {
            run30.setText(" - " + generalfundofknowledgedeficitsbox.getText());
        }
        run30.addBreak();

        String intellect = " ";

        if (intellectaboveaverage.isSelected() == true) {
            intellect = intellect + "Above Average, ";
        }
        if (intellectaverage.isSelected() == true) {
            intellect = intellect + "Average, ";
        }
        if (intellectbelowaverage.isSelected() == true) {
            intellect = intellect + "Below Average, ";
        }

        if (intellect.length() > 2) {
            intellect = intellect.substring(0, intellect.length() - 2);
            intellect = intellect.trim();
        }

        run30.setText("Intellect: " + intellect);
        if (intellectbelowaverage.isSelected() == true) {
            run30.setText(" - " + intellectbelowaveragebox.getText());
        }
        run30.addBreak();

        String abstraction = " ";

        if (abstractionintact.isSelected() == true) {
            abstraction = abstraction + "Intact, ";
        }
        if (abstractionconcrete.isSelected() == true) {
            abstraction = abstraction + "Concrete, ";
        }
        if (abstractionidiosyncratic.isSelected() == true) {
            abstraction = abstraction + "Idiosyncratic, ";
        }

        if (abstraction.length() > 2) {
            abstraction = abstraction.substring(0, abstraction.length() - 2);
            abstraction = abstraction.trim();
        }

        run30.setText("Abstraction: " + abstraction);
        run30.addBreak();

        String judgement = " ";

        if (judgementintact.isSelected() == true) {
            judgement = judgement + "Intact, ";
        }
        if (judgementimpaired.isSelected() == true) {
            judgement = judgement + "Impaired -  ";
        }
        if (judgementminimal.isSelected() == true) {
            judgement = judgement + "Minimal, ";
        }
        if (judgementmoderate.isSelected() == true) {
            judgement = judgement + "Moderate, ";
        }
        if (judgementsevere.isSelected() == true) {
            judgement = judgement + "Severe, ";
        }

        if (judgement.length() > 2) {
            judgement = judgement.substring(0, judgement.length() - 2);
            judgement = judgement.trim();
        }

        run30.setText("Judgement: " + judgement);
        run30.addBreak();

        String insight = " ";

        if (insightintact.isSelected() == true) {
            insight = insight + "Intact, ";
        }
        if (insightimpaired.isSelected() == true) {
            insight = insight + "Impaired -  ";
        }
        if (insightminimal.isSelected() == true) {
            insight = insight + "Minimal, ";
        }
        if (insightmoderate.isSelected() == true) {
            insight = insight + "Moderate, ";
        }
        if (insightsevere.isSelected() == true) {
            insight = insight + "Severe, ";
        }

        if (insight.length() > 2) {
            insight = insight.substring(0, insight.length() - 2);
            insight = insight.trim();
        }

        run30.setText("Insight: " + insight);
        run30.addBreak();
        run30.addBreak();

        run31.setUnderline(UnderlinePatterns.SINGLE);
        run31.setBold(true);
        run31.setText("Clinical Notes pertaining to MSE");
        run31.addBreak();
        run32.setBold(false);
        run32.setText(clinicalnotes.getText());
        run32.addBreak();
        run32.addBreak();

        run33.setBold(true);
        run33.setText("Diagnosis: ");
        run33.addBreak();

        run34.setBold(false);
        run34.setText("Axis I: " + axis1.getText());
        run34.addBreak();
        run34.setText("Axis II: " + axis2.getText());
        run34.addBreak();
        run34.setText("Axis III: " + axis3.getText());
        run34.addBreak();
        run34.setText("Axis IV: " + axis4.getText());
        run34.addBreak();

        String a4cb = " ";

        if (a4none.isSelected() == true) {
            a4cb = a4cb + "None, ";
        }
        if (a4primarysupportgroup.isSelected() == true) {
            a4cb = a4cb + "Primary Support Group, ";
        }
        if (a4partnerrelationalproblems.isSelected() == true) {
            a4cb = a4cb + "Partner Relational Problems, ";
        }
        if (a4parentchildrelationalproblems.isSelected() == true) {
            a4cb = a4cb + "Parent Child Relational Problems, ";
        }
        if (a4socialenvironment.isSelected() == true) {
            a4cb = a4cb + "Social Environment, ";
        }
        //a4occupation, a4economics, a4legalsystem, a4education, a4housing, 
        //a4noncompliancewithtreatment, a4other, axis5none;
        if (a4occupation.isSelected() == true) {
            a4cb = a4cb + "Occupation, ";
        }
        if (a4economics.isSelected() == true) {
            a4cb = a4cb + "Economics, ";
        }
        if (a4legalsystem.isSelected() == true) {
            a4cb = a4cb + "Legal System, ";
        }
        if (a4education.isSelected() == true) {
            a4cb = a4cb + "Education, ";
        }
        if (a4housing.isSelected() == true) {
            a4cb = a4cb + "Housing, ";
        }
        if (a4noncompliancewithtreatment.isSelected() == true) {
            a4cb = a4cb + "Noncompliance With Treatment, ";
        }
        if (a4other.isSelected() == true) {
            a4cb = a4cb + "Other, ";
        }

        if (a4cb.length() > 2) {
            a4cb = a4cb.substring(0, a4cb.length() - 2);
            a4cb = a4cb.trim();
        }

        run34.setText(a4cb);
        if (a4other.isSelected() == true) {
            run34.setText(" - " + axis4otherbox.getText());
        }
        run34.addBreak();

        run34.setText("Axis V: GAF " + "Current: " + axis5current.getText() + "  Highest in Past Year: "
                + axis5highestinpastyear.getText());
        if (axis5none.isSelected() == true) {
            run34.setText("   None");
        }
        run34.addBreak();
        run34.addBreak();

        run35.setUnderline(UnderlinePatterns.SINGLE);
        run35.setBold(true);
        run35.setText("Reccommendations and Plans");
        run35.addBreak();

        run36.setBold(false);
        run36.setText("Diagnosis and treatment options discussed with the patient? - ");
        if (treatmentplancheckbox1.isSelected() == true) {
            run36.setText("Yes");
        } else {
            run36.setText("No");
        }
        run36.addBreak();

        run36.addBreak();

        //run36.setText("Treatment Plan: " + treatmentplanbox1.getText());

        run36.setText("Treatment Plan: ");

        String[] tpLines = treatmentplanbox1.getText().split("\n");

        for (int i = 0; i < tpLines.length; i++) {
            run36.setText(tpLines[i]);
            run36.addBreak();
        }

        run36.addBreak();
        run36.addBreak();

        run36.setText(
                "Discussed that any overuse or abuse of prescription Benzodiazepines could result in patient being discharged from the practice. - ");
        if (treatmentplancheckbox2.isSelected() == true) {
            run36.setText("Yes");
        } else {
            run36.setText("No");
        }
        run36.addBreak();

        run36.setText("Nevada Prescription Monitoring Board Reviewed? - ");
        if (treatmentplancheckbox3.isSelected() == true) {
            run36.setText("Yes");
        } else {
            run36.setText("No");
        }
        run36.addBreak();
        run36.setText(treatmentplantextfield.getText());
        run36.addBreak();
        run36.addBreak();

        run37.setUnderline(UnderlinePatterns.SINGLE);
        run37.setItalic(true);
        run37.setText("Medication Prescribed");
        run37.addBreak();

        run38.setBold(false);
        run38.setText(treatmentplanbox2.getText());
        run38.addBreak();
        run38.addBreak();

        run39.setUnderline(UnderlinePatterns.SINGLE);
        run39.setBold(true);
        run39.setText("Side Effects Discussed: ");
        run39.addBreak();

        run40.setBold(false);

        String se = " ";

        if (riskforreboundhypertension.isSelected() == true) {
            se = se + "Risk For Rebound Hypertension, ";
        }
        if (complexsleeprelatedbehavior.isSelected() == true) {
            se = se + "Complex Sleep Related Behavior, ";
        }
        if (ssoftoxicity.isSelected() == true) {
            se = se + "S/S of Toxicity, ";
        }
        if (withdrawalsyndrome.isSelected() == true) {
            se = se + "Withdrawal Syndrome, ";
        }
        if (riskforaddiction.isSelected() == true) {
            se = se + "Risk for Addiction, ";
        }
        if (seizures.isSelected() == true) {
            se = se + "Seizures, ";
        }
        if (prolongedqtc.isSelected() == true) {
            se = se + "Prolonged QTC, ";
        }
        if (tardivedyskinesiadystonia.isSelected() == true) {
            se = se + "Tardive Dyskinesia/Dystonia, ";
        }
        if (acuteneurologicalse.isSelected() == true) {
            se = se + "Acute Neurological SE, ";
        }
        if (metabolicsyndrome.isSelected() == true) {
            se = se + "Metabolic Syndrome, ";
        }

        //decreasedeffectivenessofobc, teratogenicity, hyponatremia, hypothyroidism, rashsjsyndrome, 
        //weightgainloss, constipation, drymouth, increasedriskofsi, hyperprolactinemia, serotoninsyndrome, 
        //hairloss, hypotension, htn, dizziness, insomnia, sedation, sexual, gi;
        if (decreasedeffectivenessofobc.isSelected() == true) {
            se = se + "Decreased Effectiveness of OBC, ";
        }
        if (teratogenicity.isSelected() == true) {
            se = se + "Teratogenicity- ";
            se = se + sebox2.getText() + ", ";
        }
        if (hyponatremia.isSelected() == true) {
            se = se + "Hyponatremia, ";
        }
        if (hypothyroidism.isSelected() == true) {
            se = se + "Hypothyroidism, ";
        }
        if (rashsjsyndrome.isSelected() == true) {
            se = se + "Rash - SJ Syndrome- ";
            se = se + sebox1.getText() + ", ";
        }
        if (weightgainloss.isSelected() == true) {
            se = se + "Weight Gain/Loss, ";
        }
        if (constipation.isSelected() == true) {
            se = se + "Constipation, ";
        }
        if (drymouth.isSelected() == true) {
            se = se + "Dry Mouth, ";
        }
        if (increasedriskofsi.isSelected() == true) {
            se = se + "Increased Risk of SI, ";
        }
        if (hyperprolactinemia.isSelected() == true) {
            se = se + "Hyperprolactinemia, ";
        }
        if (serotoninsyndrome.isSelected() == true) {
            se = se + "Serotonin Syndrome, ";
        }
        if (hairloss.isSelected() == true) {
            se = se + "Hair Loss, ";
        }
        if (hypotension.isSelected() == true) {
            se = se + "Hypotension, ";
        }
        if (htn.isSelected() == true) {
            se = se + "HTN, ";
        }
        if (dizziness.isSelected() == true) {
            se = se + "Dizziness, ";
        }
        if (insomnia.isSelected() == true) {
            se = se + "Insomnia, ";
        }
        if (sedation.isSelected() == true) {
            se = se + "Sedation, ";
        }
        if (sexual.isSelected() == true) {
            se = se + "Sexual, ";
        }
        if (gi.isSelected() == true) {
            se = se + "GI, ";
        }

        if (se.length() > 2) {
            se = se.substring(0, se.length() - 2);
            se = se.trim();
        }

        run40.setText(se);
        run40.addBreak();
        run40.addBreak();

        run41.setUnderline(UnderlinePatterns.SINGLE);
        run41.setBold(true);
        run41.setText("Labs:");
        run41.addBreak();

        run42.setBold(false);

        String labs = " ";

        if (vitd.isSelected() == true) {
            labs = labs + "Vit D, ";
        }

        if (hivscreen.isSelected() == true) {
            labs = labs + "HIV Screen, ";
        }
        if (vitaminb12folicacid.isSelected() == true) {
            labs = labs + "Vitamin B12/Folic Acid, ";
        }

        if (ua.isSelected() == true) {
            labs = labs + "UA, ";
        }

        if (uds.isSelected() == true) {
            labs = labs + "UDS, ";
        }

        if (selectrolyte.isSelected() == true) {
            labs = labs + "S Electrolyte, ";
        }

        if (lithium.isSelected() == true) {
            labs = labs + "Lithium, ";
        }

        if (lamictallevel.isSelected() == true) {
            labs = labs + "Lamictal Level, ";
        }

        if (trileptallevel.isSelected() == true) {
            labs = labs + "Trileptal Level, ";
        }

        if (depakotelevel.isSelected() == true) {
            labs = labs + "Depakote Level, ";
        }

        if (bmp.isSelected() == true) {
            labs = labs + "BMP, ";
        }

        if (tft.isSelected() == true) {
            labs = labs + "TFT, ";
        }

        if (lft.isSelected() == true) {
            labs = labs + "LFT, ";
        }

        if (hgba1c.isSelected() == true) {
            labs = labs + "HGB A1C, ";
        }

        if (lipidprofile.isSelected() == true) {
            labs = labs + "Lipid Profile, ";
        }

        if (cmp.isSelected() == true) {
            labs = labs + "CMP, ";
        }

        if (cbc.isSelected() == true) {
            labs = labs + "CBC, ";
        }
        if (blanklabs.isSelected() == true) {
            labs = labs + labstextfield.getText() + ", ";
        }

        if (labs.length() > 2) {
            labs = labs.substring(0, labs.length() - 2);
            labs = labs.trim();
        }

        run42.setText(labs);

        run42.addBreak();
        run42.addBreak();

        run42Bold.setBold(true);
        run42Bold.setText(
                "Verbal informed consent obtained from patient for trial of " + ebox1.getText() + ": ");

        if (yes1.isSelected() == true) {
            run42Bold.setText("Yes");
        }
        if (no1.isSelected() == true) {
            run42Bold.setText("No");
        }

        run42Bold.addBreak();

        run42Bold.setText("Risks/benefits of prescribed medications discussed with patient: ");

        if (yes2.isSelected() == true) {
            run42Bold.setText("Yes");
        }
        if (no2.isSelected()) {
            run42Bold.setText("No");
        }

        run42Bold.addBreak();
        run42Bold.addBreak();

        String end = "", end2 = "";

        if (riskofsuicidelow.isSelected() == true) {
            end = end + "Low, ";
        }

        if (riskofsuicidemoderate.isSelected() == true) {
            end = end + "Moderate, ";
        }

        if (riskofsuicidehigh.isSelected() == true) {
            end = end + "High, ";
        }

        if (riskofsuicidemodifiableriskfactorsaddressed.isSelected() == true) {
            end = end + "Modifiable Risk Factors Addressed, ";
        }

        if (dangertootherslow.isSelected() == true) {
            end2 = end2 + "Low, ";
        }

        if (dangertoothersmoderate.isSelected() == true) {
            end2 = end2 + "Moderate, ";
        }

        if (dangertoothershigh.isSelected() == true) {
            end2 = end2 + "High, ";
        }

        if (dangertoothersmodifiableriskfactorsaddressed.isSelected() == true) {
            end2 = end2 + "Modifiable Risk Factors Addressed, ";
        }

        if (end.length() > 2) {
            end = end.substring(0, end.length() - 2);
            end = end.trim();
        }

        if (end2.length() > 2) {
            end2 = end2.substring(0, end2.length() - 2);
            end2 = end2.trim();
        }

        run42Bold.setText("Risk of Suicide/Self-Harm: " + end);
        run42Bold.addBreak();
        run42Bold.setText("Danger to others: " + end2);
        run42Bold.addBreak();
        run42Bold.addBreak();
        run42Bold.addBreak();
        run42Bold.addBreak();

        if (partnerSigned == true) {
            if (businesscardprovided.isSelected()) {
                runPre43.setText("Business Card Provided: Yes");
                runPre43.addBreak();
            } else {
                runPre43.setText("Business Card Provided: No");
                runPre43.addBreak();
            }

            if (discussedassistant.isSelected()) {
                if (who.getText() != null || who.getText() != "" || who.getText() != " ") {
                    runPre43.setText("Discussed with [" + who.getText()
                            + "] accompanying the patient that I am a physician assistant");
                    runPre43.addBreak();
                } else {
                    runPre43.setText("Discussed with patient that I am a physician assistant");
                    runPre43.addBreak();
                }

            } else {

            }

            //runPre43.addBreak();
            //runPre43.addBreak();

            run43.setBold(true);
            run43.setText(
                    "Signature: This Document Has Been Digitally Signed By Izabella Ostolski, PA-C            Date: ");
            DateFormat dateFormat = new SimpleDateFormat("MM-dd-yyyy");
            Date date = new Date();
            String alpha = dateFormat.format(date);
            run43.setText(alpha);
        }

        if (dccSigned == true) {
            run44.addBreak();
            run44.addBreak();
            run44.addBreak();
            run44.setBold(false);
            run44.setItalic(true);
            //run44.setTextPosition(20);
            run44.setText("I have reviewed and discussed the case. I agree with the current treatment plan.");
            run44.addBreak();
            //run44.setText(signaturenotes.getText());
            //run44.addBreak();
            run46.setBold(true);
            run46.setText(
                    "Signature: This Document Has Been Digitally Signed By David Zhvikov MD           Date: ");
            DateFormat dateFormat = new SimpleDateFormat("MM-dd-yyyy");
            Date date = new Date();
            String alpha = dateFormat.format(date);
            run46.setText(alpha);

            try {
                //code prac'k wrkoxx
                /*FileInputStream is = new FileInputStream("C:/Users/Quiggy/Desktop/javascript-based psych forms/sig.bmp");
                //doc.addPictureData(IOUtils.toByteArray(is), doc.PICTURE_TYPE_BMP)
                        
                XWPFParagraph title = doc.createParagraph();    
                XWPFRun imageRun = title.createRun();
                imageRun.setText("Fig.1 A Natural Scene");
                imageRun.setBold(true);
                title.setAlignment(ParagraphAlignment.CENTER);
                imageRun.addPicture(is, XWPFDocument.PICTURE_TYPE_BMP, "sig.bmp", 300, 200);*/

                //String picId = "C:/Users/Quiggy/Desktop/javascript-based psych forms/sig1.png";
                //doc.addPictureData(new FileInputStream("C:/Users/Quiggy/Desktop/javascript-based psych forms/sig1.png"), XWPFDocument.PICTURE_TYPE_PNG);  
                //doc.add

                //doc.createPicture(picId, doc.getNextPicNameNumber(XWPFDocument.PICTURE_TYPE_PNG), 200, 150);  

                //String imgFile = "C:/Users/Quiggy/Desktop/javascript-based psych forms/sig1.png";
                //FileInputStream is = new FileInputStream(picId);
                //run43.addBreak();
                //run43.addPicture(is, XWPFDocument.PICTURE_TYPE_PNG, picId, 200, 300); // 200x200 pixels
                //run43.addPicture(is, XWPFDocument.PICTURE_TYPE_JPEG, null, 0, 100);
                //run43.add
                //is.close();
            } catch (Exception anException) {
                //System.out.println(anException);

                //add the selected ones to the arraylist, and remove these from the second array list. print the first arraylist in bold, and then print the second arraylist unbolded.

            }
        }

        //Find: laundry bags(3), black pants (cargos), 2nd scientific calculator, iPAD mini CHARGER

        //Daskin NOW 36C
        //Masi pants
        //google jacket model number

        //dcc's old phone (with the lb, lx, & a lockscreen pic:)

        //"Enter the Physician's Assistant Passcode OR the Physician's Passcode to enable/unlock editing"

        //general-access password: dolphin-->dolphin92
        //Isabella's Password: siberianplatypus
        //Your Password: protooncogene-->protooncogene6

        //the "go-to" choice for disorganized writers/authors

        //also make an xml and php -based web chat application to complement f f
        //code this in visual studio with ASP.NET
        //that IBM? tutorial with the "free website" thing

        /*if(single.isSelected())
        {   
        run8.setItalic(true);
        run8.setBold(true);
        run8.setText("      Single");
        }
        else
        {
        run8.setItalic(false);
        run8.setBold(false);
        run8.setText("      Single");
        }
                
        if(engaged.isSelected())
        {
        run9.setItalic(true);
        run9.setBold(true);
        run9.setText("      Engaged");
        }
        else
        {
        run9.setBold(false);
        run9.setItalic(false);
        run9.setText("      Engaged");
        }
        //but not (both AT THE SAME TIME/ARE TRUE/HOLD)
        if(married.isSelected())
        {
        run10.setItalic(true);
        run10.setBold(true);
        run10.setText("     Married");
        }//nightmares, when they occurred, were less terrifying, somehow.
        else
        {
        run10.setItalic(false);
        run10.setBold(false);
        run10.setText("     Married");
        }//is fundamentally incomprehensible from the level of c at which you've considered it
        //because NEITHER are true
        //there is no
        if(seperated.isSelected())
        {
        run11.setItalic(true);
        run11.setBold(true);
        run11.setText("     Seperated");
        }
        else
        {
        run11.setItalic(false);
        run11.setBold(false);
        run11.setText("     Seperated");
        }
                
        if(divorced.isSelected())
        {
        run12.setItalic(true);
        run12.setBold(true);
        run12.setText("     Divorced");
        }//there is only choice...choice is the only thing left to identify/indicate [that] individuality [exists indeed]
        else
        {
        run12.setItalic(false);
        run12.setBold(false);
        run12.setText("     Divorced");
        }
                
        if(commonlawspouse.isSelected())
        {
        run13.setItalic(true);
        run13.setBold(true);
        run13.setText("     Common Law Spouse");
        }
        else
        {
        run13.setItalic(false);
        run13.setBold(false);
        run13.setText("     Common Law Spouse");
        }
                
        if(cohabiting.isSelected())
        {
        run14.setItalic(true);
        run14.setBold(true);
        run14.setText("     Cohabiting");
        }
        else
        {
        run14.setItalic(false);
        run14.setBold(false);
        run14.setText("     Cohabiting");
        }*/

        //run is created here if(divorced.isSelected == "true"){run.setBold(true); run.setText("divorced");} else {run.setBold(false); run.setText("divorced")}
        //single, engaged, married, seperated, divorced, commonlawspouse, cohabiting; 

        //printDOB(doc);

        //one (not-so-great) solution to the numerous runs problem: list everything to be bolded first (array 1- run 1), and then everything else (array 2- run 2)

        //doc.createParagraph().createRun().setText("           " + paragraphs.get(c).toString());
        //doc.createParagraph().createRun().addBreak();

        doc.write(outstream);
        outstream.close();

        //paraRun.setText(Primary.getText());

        //doc.createParagraph().createRun().addBreak();                 //inserts a line break
        //doc.createParagraph().createRun().setText("blah");            //creates another paragraph

        /*for(int c = 0; c < paragraphs.size(); c++)
        {
             /*XWPFParagraph p = doc.createParagraph(); //Paragraph
             XWPFRun run = p.createRun();  //Where the text will be written from
             run.setText("\t");*/

        /*            XWPFParagraph p = doc.createParagraph(); //Paragraph
            XWPFRun run = p.createRun();  //Where the text will be written from
                    
            String currentParagraph = paragraphs.get(c).toString();
            for(int d = 0; d < currentParagraph.length(); d++)
            {
        if(currentParagraph.charAt(d) == '@')
        {
            currentParagraph = currentParagraph.substring(d+1, currentParagraph.length() - 2);
                    
            run.setBold(true);
                    
                    
        }
        else
        {
            //run.setBold(false);
        }
            }
                    
            run.setText("           " + currentParagraph);
            //doc.createParagraph().createRun().setText("           " + paragraphs.get(c).toString());
            //doc.createParagraph().createRun().addBreak();
        }
                
                
        doc.write(outstream);
        outstream.close();
        //JOptionPane.showConfirmDialog(null, "Are you sure you want to create the word document?");
                
        //Makes the chapter titles bold and removes the "@" & "-"
                
        JOptionPane.showMessageDialog(null, "Document Successfully Created. The program/AA will now exit");
        System.exit(0);*/

    } catch (Exception e) {

    }
}

From source file:pe.gob.onpe.rae.controller.registro.registroController.java

@RequestMapping(value = "generateFVDoc/{codExpediente}", method = RequestMethod.GET)
public void generateFVDoc(HttpServletRequest request, @PathVariable("codExpediente") int codExpediente,
        HttpServletResponse response) {//from   w w w  .ja v  a2 s  .co m
    try {
        ServletContext sc = request.getSession().getServletContext();

        Expediente expediente = new Expediente(codExpediente);
        expediente = expedienteDAO.find(expediente);

        Ambito amb = new Ambito(expediente.getAmbito().getId());
        amb = ambitoDAO.find(amb);

        int totalElectoresRemitidos = expedientePadronDAO.getCountByExpediente(expediente);
        int totalElectoresIncorporados = expedientePadronDAO.getCountByExpedienteAndEstado(expediente,
                Parametros.ESTADO_ELECTOR_ACTIVO);

        JsonParser jsonParser = new JsonParser();
        JsonObject jsonObject = (JsonObject) jsonParser.parse(amb.getInformacion());
        String nombre = jsonObject.get("nombres").toString() + " "
                + jsonObject.get("apellidoPaterno").toString() + " "
                + jsonObject.get("apellidoMaterno").toString();

        InputStream is = registroController.class.getResourceAsStream("/ejemplo.docx");
        XWPFDocument document = new XWPFDocument(is);

        XWPFHeaderFooterPolicy policy = document.getHeaderFooterPolicy();
        if (policy == null) {
            CTSectPr sectPr = document.getDocument().getBody().addNewSectPr();
            policy = new XWPFHeaderFooterPolicy(document, sectPr);
        }

        if (policy.getDefaultHeader() == null && policy.getFirstPageHeader() == null
                && policy.getDefaultFooter() == null) {
            XWPFFooter footerD = policy.getFooter(1);// createFooter(policy.DEFAULT);
            XWPFRun run = footerD.getParagraphs().get(0).createRun();
            run.setText("usuario");
            XWPFParagraph paragraph = footerD.createParagraph();
            paragraph.setAlignment(ParagraphAlignment.DISTRIBUTE);
            run = paragraph.createRun();
            run.setFontFamily("Arial");
            run.setFontSize(8);
            run.setText(
                    "Jr.Washington N 1894, Cercado de Lima. Central Telefonica: 417-0630 www.onpe.gob.pe informes@onpe.gob.pe");

        }

        XWPFParagraph paragraph = document.createParagraph();

        XWPFRun run = paragraph.createRun();
        run.setFontSize(11);
        run.setFontFamily("Arial");
        run.setText("Lima,");
        run.addBreak();

        paragraph = document.createParagraph();
        run = paragraph.createRun();
        run.setFontSize(11);
        run.setFontFamily("Arial");
        run.setBold(true);
        run.setText("OFICIO N       -2016-GPP/ONPE");
        run.setUnderline(UnderlinePatterns.SINGLE);
        run.addBreak();

        paragraph = document.createParagraph();
        run = paragraph.createRun();
        run.setFontSize(11);
        run.setFontFamily("Arial");
        run.setText("Seor");

        XWPFRun run1 = paragraph.createRun();
        run1.setFontSize(11);
        run1.setFontFamily("Arial");
        run1.setText(nombre.replace("\"", ""));
        run1.setBold(true);
        run1.addBreak();

        XWPFRun run2 = paragraph.createRun();
        run2.setFontSize(11);
        run2.setFontFamily("Arial");
        run2.setText(jsonObject.get("cargo").toString().replace("\"", ""));
        run2.addBreak();
        run2.setText("Centro Poblado " + amb.getNombreAmbito());
        run2.addBreak();
        run2.setText("Av. 28 de Julio S/N Centro Cvico Huacrachuco - Municipalidad Provincial de "
                + amb.getProvincia());
        run2.addBreak();
        run2.setText(amb.getDepartamento() + " - " + amb.getProvincia() + " - " + amb.getDistrito());
        run2.addBreak();

        run2 = paragraph.createRun();
        run2.setFontSize(11);
        run2.setFontFamily("Arial");
        run2.setUnderline(UnderlinePatterns.WORDS);
        run2.setText("Presente");

        run2 = paragraph.createRun();
        run2.setFontSize(11);
        run2.setFontFamily("Arial");
        run2.setText(".-");

        paragraph = document.createParagraph();
        run.addBreak();
        run = paragraph.createRun();
        run.setFontSize(11);
        run.setFontFamily("Arial");
        run.addBreak();
        run.setText("Asunto");
        run.addTab();
        run.addTab();
        run.setText(": SOLICITUD DE CREACIN DE MESA DE SUFRAGIO.");
        run.addBreak();

        paragraph = document.createParagraph();
        run = paragraph.createRun();
        run.setFontSize(11);
        run.setFontFamily("Arial");
        run.setText("Referencia");
        run.addTab();
        run.setText(": OFICIO N 087-2016/M-CP.CHOCOBAMBA (16AGO2016) - Exp. " + expediente.getExpediente());
        run.addBreak();

        paragraph = document.createParagraph();
        paragraph.setAlignment(ParagraphAlignment.THAI_DISTRIBUTE);
        run = paragraph.createRun();
        run.setFontSize(11);
        run.setFontFamily("Arial");
        run.setText(
                "Me dirijo a usted con relacin al documento de la referencia con la finalidad de hacer de su "
                        + "conocimiento que se ha cumplido con todos los requisitos que dan inicio al trmite de "
                        + "instalacin de mesas de sufragio en el Centro Poblado " + amb.getNombreAmbito()
                        + ", distrito " + amb.getDistrito() + ", " + "provincia " + amb.getProvincia()
                        + ", departamento " + amb.getDepartamento() + ".");
        paragraph = document.createParagraph();
        paragraph.setAlignment(ParagraphAlignment.THAI_DISTRIBUTE);
        run = paragraph.createRun();
        run.setFontSize(11);
        run.setFontFamily("Arial");
        run.addBreak();
        run.setText("Al respecto, el mencionado expediente contiene un listado de electores que solicitan ser "
                + "parte de la mesa de sufragio de la localidad " + amb.getNombreAmbito()
                + ", el cual, luego de la validacin " + "realizada, se informa que podrn ser incorporados "
                + totalElectoresIncorporados + " electores del total de " + totalElectoresRemitidos
                + " registros "
                + "de electores remitidos. Se adjunta un cuadro resumen con las observaciones mencionadas.");
        paragraph = document.createParagraph();
        paragraph.setAlignment(ParagraphAlignment.THAI_DISTRIBUTE);
        run = paragraph.createRun();
        run.setFontSize(11);
        run.setFontFamily("Arial");
        run.addBreak();
        run.setText(
                "Asimismo, se programar un viaje para la verificacin de rutas, tiempos y servicios de la "
                        + "localidad, la cual se coordinar previamente con las autoridades del centro poblado a fin de "
                        + "programarla adecuadamente; luego de lo cual se emitir un informe de respuesta al "
                        + "resultado de la solicitud, que de ser positivo, conllevara a la instalacin de mesas de sufragio "
                        + "en el centro poblado en mencin, con miras a las ");
        run = paragraph.createRun();
        run.setFontSize(11);
        run.setFontFamily("Arial");
        run.setBold(true);
        run.setText("Elecciones Regionales y Municipales de 2018.");
        paragraph = document.createParagraph();
        paragraph.setAlignment(ParagraphAlignment.THAI_DISTRIBUTE);
        run = paragraph.createRun();
        run.setFontSize(11);
        run.setFontFamily("Arial");
        run.addBreak();
        run.setText("Finalmente, de requerir mayor informacin, agradeceremos se comunique con nosotros al "
                + "telefono 417-0630 anexo 8484 o al 8481.");
        paragraph = document.createParagraph();
        paragraph.setAlignment(ParagraphAlignment.THAI_DISTRIBUTE);
        run = paragraph.createRun();
        run.setFontSize(11);
        run.setFontFamily("Arial");
        run.addBreak();
        run.setText("Sin otro particular.");

        paragraph = document.createParagraph();
        paragraph.setAlignment(ParagraphAlignment.THAI_DISTRIBUTE);
        run = paragraph.createRun();
        run.setFontSize(11);
        run.setFontFamily("Arial");
        run.addBreak();
        run.addBreak();
        run.setText("Atentamente,");
        response.setContentType("application/vnd.openxmlformats-officedocument.wordprocessingml.document");
        document.write(response.getOutputStream());
    } catch (Exception ex) {
        Logger.getLogger(registroController.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:ro.dabuno.office.integration.SimpleDocument.java

License:Apache License

public static void main(String[] args) throws Exception {
    XWPFDocument doc = new XWPFDocument();

    XWPFParagraph p0 = doc.createParagraph();
    XWPFRun r0 = p0.createRun();/*from  w ww  . j  a v  a2  s .  c o  m*/
    r0.setBold(false);
    r0.setText("Domnule");
    XWPFRun r00 = p0.createRun();
    r00.setBold(true);
    r00.setText(" Ionescu Ion");

    XWPFParagraph p1 = doc.createParagraph();
    p1.setAlignment(ParagraphAlignment.CENTER);
    p1.setBorderBottom(Borders.DOUBLE);
    p1.setBorderTop(Borders.DOUBLE);

    p1.setBorderRight(Borders.DOUBLE);
    p1.setBorderLeft(Borders.DOUBLE);
    p1.setBorderBetween(Borders.SINGLE);

    p1.setVerticalAlignment(TextAlignment.TOP);

    XWPFRun r1 = p1.createRun();
    r1.setBold(true);
    r1.setText("The quick brown fox");
    r1.setBold(true);
    r1.setFontFamily("Courier");
    r1.setUnderline(UnderlinePatterns.DOT_DOT_DASH);
    r1.setTextPosition(100);

    XWPFParagraph p2 = doc.createParagraph();
    p2.setAlignment(ParagraphAlignment.RIGHT);

    //BORDERS
    p2.setBorderBottom(Borders.DOUBLE);
    p2.setBorderTop(Borders.DOUBLE);
    p2.setBorderRight(Borders.DOUBLE);
    p2.setBorderLeft(Borders.DOUBLE);
    p2.setBorderBetween(Borders.SINGLE);

    XWPFRun r2 = p2.createRun();
    r2.setText("jumped over the lazy dog");
    r2.setStrike(true);
    r2.setFontSize(20);

    XWPFRun r3 = p2.createRun();
    r3.setText("and went away");
    r3.setStrike(true);
    r3.setFontSize(20);
    r3.setSubscript(VerticalAlign.SUPERSCRIPT);

    XWPFParagraph p3 = doc.createParagraph();
    p3.setWordWrap(true);
    p3.setPageBreak(true);

    //p3.setAlignment(ParagraphAlignment.DISTRIBUTE);
    p3.setAlignment(ParagraphAlignment.BOTH);
    p3.setSpacingLineRule(LineSpacingRule.EXACT);

    p3.setIndentationFirstLine(600);

    XWPFRun r4 = p3.createRun();
    r4.setTextPosition(20);
    r4.setText("To be, or not to be: that is the question: " + "Whether 'tis nobler in the mind to suffer "
            + "The slings and arrows of outrageous fortune, " + "Or to take arms against a sea of troubles, "
            + "And by opposing end them? To die: to sleep; ");
    r4.addBreak(BreakType.PAGE);
    r4.setText("No more; and by a sleep to say we end " + "The heart-ache and the thousand natural shocks "
            + "That flesh is heir to, 'tis a consummation " + "Devoutly to be wish'd. To die, to sleep; "
            + "To sleep: perchance to dream: ay, there's the rub; " + ".......");
    r4.setItalic(true);
    //This would imply that this break shall be treated as a simple line break, and break the line after that word:

    XWPFRun r5 = p3.createRun();
    r5.setTextPosition(-10);
    r5.setText("For in that sleep of death what dreams may come");
    r5.addCarriageReturn();
    r5.setText("When we have shuffled off this mortal coil," + "Must give us pause: there's the respect"
            + "That makes calamity of so long life;");
    r5.addBreak();
    r5.setText("For who would bear the whips and scorns of time,"
            + "The oppressor's wrong, the proud man's contumely,");

    r5.addBreak(BreakClear.ALL);
    r5.setText("The pangs of despised love, the law's delay," + "The insolence of office and the spurns"
            + ".......");

    FileOutputStream out = new FileOutputStream("simple.docx");
    doc.write(out);
    out.close();

}

From source file:service.Read_Write_File.java

public void SetDOCX_DT(List<Bordereau> bordereaus, List<CorpDetat> corpDetats, List<ArticleChp1> articlechp1s,
        List<ArticleChp2> articlechp2s) throws Exception {

    //    XWPFDocument document = new XWPFDocument(); //creete a new documment 
    XWPFDocument doc = new XWPFDocument();

    //FileInputStream is = new FileInputStream("D:\\a.jpg"); 

    // doc.addPictureData(IOUtils.toByteArray(fs), doc.PICTURE_TYPE_JPEG);

    //doc.create(id,doc.getNextPicNameNumber(doc.PICTURE_TYPE_JPEG), 64, 64);
    XWPFParagraph para2 = doc.createParagraph();
    para2.setAlignment(ParagraphAlignment.CENTER);
    XWPFRun run = para2.createRun();/*from w  w w.  j ava 2s  .  co  m*/
    run.setBold(true);
    run.setFontSize(40);

    // run.addPicture(pic, doc.PICTURE_TYPE_JPEG, "3", 0, 0);

    // run.addPicture(fs, doc.PICTURE_TYPE_JPEG, blipId, 100, 100);
    //  run.addPicture(is,2, "kamal", 20, 20);
    //run.addPicture(IOUtils.toByteArray(is), doc.PICTURE_TYPE_JPEG);
    run.setText("\n \t Descriptif technique  \n ");

    // pour article d projet
    XWPFParagraph para3 = doc.createParagraph();
    // para2.setAlignment(ParagraphAlignment.CENTER);
    run = para3.createRun();
    run.setText(" I- article de votre projet :");
    run.setFontSize(18);
    run.setBold(true);

    XWPFParagraph para4 = doc.createParagraph();// pour les article chp 1
    run = para4.createRun();
    run.setText("    I-1 article chapitre1   :   \n");
    run.setFontSize(14);
    run.setBold(true);
    run.addBreak();

    int i = 1;
    for (ArticleChp1 loadarticlechp1 : articlechp1s) {// kan3amar text1 dyal articlchp1
        run = para4.createRun();
        run.setText("      " + i + ")- " + loadarticlechp1.getTitre());
        run.addBreak();
        i++;
    }
    XWPFParagraph para5 = doc.createParagraph(); // pour les articles chp2
    run = para5.createRun();
    run.setText("    I-2 article chapitre2   :   \n");
    run.setFontSize(14);
    run.setBold(true);
    run.addBreak();
    i = 1;
    for (ArticleChp2 loadarticlechp2 : articlechp2s) {// text2 dyla articlechp2
        run = para5.createRun();
        run.setText("       " + i + ")- " + loadarticlechp2.getTitre());
        run.addBreak();
        i++;
    }

    // corpdetat de projet
    XWPFParagraph para6 = doc.createParagraph();
    // para2.setAlignment(ParagraphAlignment.CENTER);
    run = para6.createRun();
    run.setText("\t II- corps dtat :");
    run.setFontSize(18);
    run.setBold(true);
    run.addBreak();
    //  run.setColor("#999");

    i = 1;
    // bouclage pourles coprs et posts dyal kola corps 
    for (CorpDetat loaDetat : corpDetats) {
        run = para6.createRun();
        run.setText("       II-" + i + "- " + loaDetat.getTitre() + "  : ");
        run.setFontSize(16);

        run.addBreak();

        int j = 1;
        for (Post loadpost : loaDetat.getPosts()) {
            run = para6.createRun();
            run.setText("                 " + i + "-" + j + ")  " + loadpost.getTitre() + " ");
            run.addBreak();
            j++;
        }
        i++;
    }

    // 
    // bordeauraux
    XWPFParagraph para = doc.createParagraph();

    run = para.createRun();
    run.setBold(true);
    run.setFontSize(18);
    run.setText("     bordereau de prix ");
    run.addBreak();
    run = para.createRun();

    //Creates a table 
    XWPFTable tab = doc.createTable();
    tab.setWidth(500);

    tab.setCellMargins(50, 200, 50, 200);

    XWPFTableRow row1 = tab.getRow(0);

    row1.getCell(0).setText("designation");
    row1.getCell(0).setColor("FF9900");

    row1.addNewTableCell().setText("Unite");
    row1.getCell(1).setColor("FF9900");

    row1.addNewTableCell().setText("Quantite");
    row1.getCell(2).setColor("FF9900");

    row1.addNewTableCell().setText("prix");
    row1.getCell(3).setColor("FF9900");

    row1.addNewTableCell().setText("montant");
    row1.getCell(4).setColor("FF9900");
    i = 1;
    for (Bordereau loadbordereau : bordereaus) {

        XWPFTableRow loadRow = null;
        loadRow = tab.createRow();

        loadRow.getCell(0).setText(loadbordereau.getDesignation() + "");
        loadRow.getCell(1).setText(loadbordereau.getUnite());
        if (loadbordereau.getQuanite() == 0) {
            loadRow.getCell(2).setText("");

        } else {
            loadRow.getCell(2).setText(loadbordereau.getQuanite() + "");
        }
        if (loadbordereau.getPrix() == 0) {
        } else {
            loadRow.getCell(3).setText(loadbordereau.getPrix() + "");
        }
        if (loadbordereau.getMontant() == 0.0) {
        } else {
            loadRow.getCell(4).setText(loadbordereau.getMontant() + "");
        }

    }

    XWPFTableRow row3 = null;
    row3 = tab.createRow();
    row3.getCell(0).setText("TVA");
    row3.getCell(0).setColor("FF9900");

    XWPFTableRow row4 = null;
    row4 = tab.createRow();
    row4.getCell(0).setText("HTTC");
    row4.getCell(0).setColor("FF9900");

    try {
        doc.write(new FileOutputStream("D:\\test2.docx"));
        // InputStream pica = new FileInputStream("D:\\test2.docx");
        //FileInputStream fis = new FileInputStream("D:\\test2.docx");
        if (Desktop.isDesktopSupported()) {
            Desktop.getDesktop().open(new File("D:\\test2.docx"));
        }
    } catch (IOException ex) {

    }

}

From source file:sofmeth.mco3.gui.DRLFrame.java

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

    //TODO: need error handling to check if inputs in Fix Time etc are numbers and not letters
    XWPFDocument document = new XWPFDocument();
    try {/*from   w  w  w . j  a va2  s  .  c  o m*/
        FileOutputStream out = new FileOutputStream(new File("defect recording log.docx"));
        //making of title
        XWPFParagraph para = document.createParagraph();
        para.setAlignment(ParagraphAlignment.CENTER);
        para.setSpacingAfter(500);
        XWPFRun run = para.createRun();
        run.setText("Defect Recording Log");
        run.setBold(true);
        run.setFontSize(16);
        //end making of title
        //adding name etc to document
        XWPFTable details = document.createTable(3, 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("Program: " + progField);
        dtlRow.getCell(1).setText("Program#: " + progNumField);
        dtlRow = details.getRow(2);
        dtlRow.getCell(0).setText("Professor: " + profField);
        dtlRow.getCell(1).setText("Language: " + langField);
        //end adding name to document
        para = document.createParagraph();
        run = para.createRun();
        run.addBreak();
        run.addBreak();
        XWPFTable table = document.createTable(6, 8);
        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 < 8; j++) {

                    switch (j) { //no formatting yet like bold etc
                    case 0:
                        row1.getCell(j).setText("Date");
                        break;
                    case 1:
                        row1.getCell(j).setText("Number");
                        break;
                    case 2:
                        row1.getCell(j).setText("Type");
                        break;
                    case 3:
                        row1.getCell(j).setText("Inject");
                        break;
                    case 4:
                        row1.getCell(j).setText("Remove");
                        break;
                    case 5:
                        row1.getCell(j).setText("Fix Time");
                        break;
                    case 6:
                        row1.getCell(j).setText("Fix Defect");
                        break;
                    case 7:
                        row1.getCell(j).setText("Description");
                        break;
                    }

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

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

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

        }
        document.write(out);

        out.close();

    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:sofmeth.mco3.gui.PIPFrame.java

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

    XWPFDocument document = new XWPFDocument();
    try {/*from   w  ww .  ja v a 2  s .  c o m*/
        FileOutputStream out = new FileOutputStream(new File("pip form.docx"));
        //start making title
        XWPFParagraph para = document.createParagraph();
        para.setAlignment(ParagraphAlignment.CENTER);
        para.setSpacingAfter(500);
        XWPFRun run = para.createRun();
        run.setText("Process Improvement Proposal(PIP)");
        run.setBold(true);
        run.setFontSize(16);
        //end making title
        //start making name table
        XWPFTable details = document.createTable(2, 2);
        //setting cell width
        CTTblWidth width = details.getCTTbl().addNewTblPr().addNewTblW();
        width.setType(STTblWidth.DXA);
        width.setW(BigInteger.valueOf(9000));
        //end setting cell width
        //details.getCTTbl().getTblPr().unsetTblBorders();
        XWPFTableRow row = details.getRow(0);
        row.getCell(0).setText("Name: " + nameField);
        row.getCell(1).setText("Date: " + nameField);
        row = details.getRow(1);
        row.getCell(0).setText("Professor: " + profField);
        row.getCell(1).setText("Program#: " + progNumField);

        para = document.createParagraph();
        run = para.createRun();
        run.addBreak();
        run.addBreak();
        //end making name table
        XWPFTable table = document.createTable(6, 2);
        width = table.getCTTbl().addNewTblPr().addNewTblW();
        width.setType(STTblWidth.DXA);
        width.setW(BigInteger.valueOf(9000));
        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 < 2; j++) {

                    switch (j) { //no formatting yet like bold etc
                    case 0:
                        row1.getCell(j).setText("Number");
                        break;
                    case 1:
                        row1.getCell(j).setText("Problem Description");
                        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 (probTable.getModel().getValueAt(i, 1) != null
                            && !probTable.getModel().getValueAt(i, j).toString().isEmpty()) {

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

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

        }
        para = document.createParagraph();
        run = para.createRun();
        run.addBreak();
        run.addBreak();
        XWPFTable table2 = document.createTable(6, 2);
        width = table2.getCTTbl().addNewTblPr().addNewTblW();
        width.setType(STTblWidth.DXA);
        width.setW(BigInteger.valueOf(9000));
        for (int i = -1; i < 6; i++) {

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

                    switch (j) { //no formatting yet like bold etc
                    case 0:
                        row1.getCell(j).setText("Number");
                        break;
                    case 1:
                        row1.getCell(j).setText("Proposal Description");
                        break;

                    }

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

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

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

        }
        para = document.createParagraph();
        run = para.createRun();
        run.addBreak();
        run.addBreak();
        table = document.createTable(2, 1);
        width = table.getCTTbl().addNewTblPr().addNewTblW();
        width.setType(STTblWidth.DXA);
        width.setW(BigInteger.valueOf(9000));
        row = table.getRow(0);
        row.getCell(0).setText("Notes and Comments");
        row = table.getRow(1);
        row.getCell(0).setText(notesArea.getText());

        document.write(out);

        out.close();

    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:sofmeth.mco3.gui.PPSFrame.java

private void doneButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_doneButtonActionPerformed
    // TODO add your handling code here:
    XWPFDocument document = new XWPFDocument();

    try {/*from  ww  w  . j  a v  a2  s. c om*/
        FileOutputStream out = new FileOutputStream(new File("PPS " + comboValue + ".docx"));

        //making of title
        XWPFParagraph para = document.createParagraph();
        para.setAlignment(ParagraphAlignment.CENTER);
        para.setSpacingAfter(500);
        XWPFRun run = para.createRun();
        run.setText("Project Plan Summary(" + comboValue + ")");
        run.setBold(true);
        run.setFontSize(16);
        //end making of title
        para = document.createParagraph();
        run = para.createRun();

        //adding name etc to document
        XWPFTable details = document.createTable(3, 2);
        //setting cell width
        CTTblWidth width = details.getCTTbl().addNewTblPr().addNewTblW();
        width.setType(STTblWidth.DXA);
        width.setW(BigInteger.valueOf(9000));
        //end setting cell width
        //details.getCTTbl().getTblPr().unsetTblBorders();
        XWPFTableRow row = details.getRow(0);
        row.getCell(0).setText("Name: " + nameField);
        row.getCell(1).setText("Date: " + dateField);
        row = details.getRow(1);
        row.getCell(0).setText("Program: " + progField);
        row.getCell(1).setText("Program#: " + progNumField);
        row = details.getRow(2);
        row.getCell(0).setText("Professor: " + profField);
        row.getCell(1).setText("Language: " + langField);

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

        if (comboValue == "4A" || comboValue == "5A") {
            XWPFTable table = document.createTable(7, 4);
            width = table.getCTTbl().addNewTblPr().addNewTblW();
            width.setType(STTblWidth.DXA);
            width.setW(BigInteger.valueOf(9000));

            //poor code ahead!

            row = table.getRow(0);
            for (int i = 0; i < 4; i++) {
                switch (i) {
                case 0:
                    row.getCell(i).setText("Summary");
                    break;
                case 1:
                    row.getCell(i).setText("Plan");
                    break;
                case 2:
                    row.getCell(i).setText("Actual");
                    break;
                case 3:
                    row.getCell(i).setText("To Date");
                    break;
                }
            }
            row = table.getRow(1);
            for (int i = 0; i < 4; i++) {
                switch (i) {
                case 0:
                    row.getCell(i).setText("LOC/Hour");
                    break;
                case 1:
                    row.getCell(i).setText(locField.getText());
                    break;
                case 2:
                    row.getCell(i).setText(locField2.getText());
                    break;
                case 3:
                    row.getCell(i).setText(locField3.getText());
                    break;
                }
            }
            row = table.getRow(2);
            row.getCell(0).setText("Planned Time");
            row.getCell(1).setText(plannedField.getText());
            row.getCell(3).setText(plannedField2.getText());

            row = table.getRow(3);
            row.getCell(0).setText("Actual Time");
            row.getCell(2).setText(actualField.getText());
            row.getCell(3).setText(actualField2.getText());

            row = table.getRow(4);
            row.getCell(0).setText("CPI");
            row.getCell(3).setText(cpiField.getText());

            row = table.getRow(5);
            for (int i = 0; i < 4; i++) {
                switch (i) {
                case 0:
                    row.getCell(i).setText("% Reused");
                    break;
                case 1:
                    row.getCell(i).setText(perreusedField.getText());
                    break;
                case 2:
                    row.getCell(i).setText(perreusedField2.getText());
                    break;
                case 3:
                    row.getCell(i).setText(perreusedField3.getText());
                    break;
                }
            }
            row = table.getRow(6);
            for (int i = 0; i < 4; i++) {
                switch (i) {
                case 0:
                    row.getCell(i).setText("% Reused");
                    break;
                case 1:
                    row.getCell(i).setText(newreusedField.getText());
                    break;
                case 2:
                    row.getCell(i).setText(newreusedField2.getText());
                    break;
                case 3:
                    row.getCell(i).setText(newreusedField3.getText());
                    break;
                }
            }
            para = document.createParagraph();
        }

        if (comboValue == "2A" || comboValue == "3A" || comboValue == "4A" || comboValue == "5A") {

            System.out.print("test");
            XWPFTable table = document.createTable(5, 4);
            width = table.getCTTbl().addNewTblPr().addNewTblW();
            width.setType(STTblWidth.DXA);
            width.setW(BigInteger.valueOf(9000));

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

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

                        switch (j) { //no formatting yet like bold etc
                        case 0:
                            row1.getCell(j).setText("Program Size");
                            break;
                        case 1:
                            row1.getCell(j).setText("Plan");
                            break;
                        case 2:
                            row1.getCell(j).setText("Actual");
                            break;
                        case 3:
                            row1.getCell(j).setText("To Date");
                            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 < 4; j++) {

                        if (loc11Table.getModel().getValueAt(i, j) != null
                                && !loc11Table.getModel().getValueAt(i, j).toString().isEmpty())
                            row.getCell(j).setText(loc11Table.getModel().getValueAt(i, j).toString());

                    }
                }

            }
            table = document.createTable(4, 4);
            for (int i = 0; i < 4; i++) {

                row = table.getRow(i);
                for (int j = 0; j < 4; j++) {

                    if (loc11Table2.getModel().getValueAt(i, j) != null
                            && !loc11Table2.getModel().getValueAt(i, j).toString().isEmpty())
                        row.getCell(j).setText(loc11Table2.getModel().getValueAt(i, j).toString());

                }

            }

            para = document.createParagraph();

        }

        XWPFTable table = document.createTable(8, 5);
        width = table.getCTTbl().addNewTblPr().addNewTblW();
        width.setType(STTblWidth.DXA);
        width.setW(BigInteger.valueOf(9000));
        //time
        for (int i = -1; i < 8; i++) {

            if (i == 7)
                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("Time in Phase");
                        break;
                    case 1:
                        row1.getCell(j).setText("Plan");
                        break;
                    case 2:
                        row1.getCell(j).setText("Actual");
                        break;
                    case 3:
                        row1.getCell(j).setText("To Date");
                        break;
                    case 4:
                        row1.getCell(j).setText("To Date %");
                        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 (timeTable.getModel().getValueAt(i, j) != null
                            && !timeTable.getModel().getValueAt(i, j).toString().isEmpty())
                        row.getCell(j).setText(timeTable.getModel().getValueAt(i, j).toString());

                }
            }
        }
        System.out.print(timeTable.getModel().getValueAt(0, 0).toString());
        //defect inject
        para = document.createParagraph();
        run = para.createRun();
        run.addBreak();
        table = document.createTable(7, 5);
        width = table.getCTTbl().addNewTblPr().addNewTblW();
        width.setType(STTblWidth.DXA);
        width.setW(BigInteger.valueOf(9000));
        for (int i = -1; i < 7; i++) {

            if (i == 6)
                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("Defects Injected");
                        break;
                    case 1:
                        row1.getCell(j).setText("Plan");
                        break;
                    case 2:
                        row1.getCell(j).setText("Actual");
                        break;
                    case 3:
                        row1.getCell(j).setText("To Date");
                        break;
                    case 4:
                        row1.getCell(j).setText("To Date %");
                        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 (defectiTable.getModel().getValueAt(i, j) != null
                            && !defectiTable.getModel().getValueAt(i, j).toString().isEmpty())

                        row.getCell(j).setText(defectiTable.getModel().getValueAt(i, j).toString());

                }
            }

        }
        //defect removed
        para = document.createParagraph();
        run = para.createRun();
        run.addBreak();

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

            if (i == 7)
                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("Time in Phase");
                        break;
                    case 1:
                        row1.getCell(j).setText("Plan");
                        break;
                    case 2:
                        row1.getCell(j).setText("Actual");
                        break;
                    case 3:
                        row1.getCell(j).setText("To Date");
                        break;
                    case 4:
                        row1.getCell(j).setText("To Date %");
                        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 (defectrTable.getModel().getValueAt(i, j) != null
                            && !defectrTable.getModel().getValueAt(i, j).toString().isEmpty())

                        row.getCell(j).setText(defectrTable.getModel().getValueAt(i, j).toString());

                }
            }
        }

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

    } catch (Exception e) {

    }
}