I need my result to print out only in the box created with a scroll bar. It has to look like this.
The Twelve Days of It
by John H. Howard
On the First day of It
My true LOVE of Computers
sent to me:
A one Gig Jump drive
On the Second day of It
My true LOVE of Computers
sent to me:
Two LCD Monitors
and A one Gig Jump drive
On the Third day of It
My true LOVE of Computers
sent to me:
Three Floppy disks
Two LCD Monitors
and A one Gig Jump drive
On the Fourth day of It
My true LOVE of Computers
sent to me:
Four 512Mg SIMM's
Three Floppy disks
Two LCD Monitors
and A one Gig Jump drive
On the Fifth day of It
My true LOVE of Computers
sent to me:
Five Zip disks
Four 512Mg SIMM's
Three Floppy disks
Two LCD Monitors
and A one Gig Jump drive
On the Sixth day of It
My true LOVE of Computers
sent to me:
Six Tape Drives
Five Zip disks
Four 512Mg SIMM's
Three Floppy disks
Two LCD Monitors
and A one Gig Jump drive
On the Seventh day of It
My true LOVE of Computers
sent to me:
Seven Java Reference Books
Six Tape Drives
Five Zip disks
Four 512Mg SIMM's
Three Floppy disks
Two LCD Monitors
and A one Gig Jump drive
On the Eighth day of It
My true LOVE of Computers
sent to me:
Eight External Hard Drives
Seven Java Reference Books
Six Tape Drives
Five Zip disks
Four 512Mg SIMM's
Three Floppy disks
Two LCD Monitors
and A one Gig Jump drive
On the Ninth day of It
My true LOVE of Computers
sent to me:
Nine Network ISP's
Eight External Hard Drives
Seven Java Reference Books
Six Tape Drives
Five Zip disks
Four 512Mg SIMM's
Three Floppy disks
Two LCD Monitors
and A one Gig Jump drive
On the Tenth day of It
My true LOVE of Computers
sent to me:
Ten Websites Java Driven
Nine Network ISP's
Eight External Hard Drives
Seven Java Reference Books
Six Tape Drives
Five Zip disks
Four 512Mg SIMM's
Three Floppy disks
Two LCD Monitors
and A one Gig Jump drive
On the Eleventh day of It
My true LOVE of Computers
sent to me:
Eleven E-Commerce Accounts
Ten Websites Java Driven
Nine Network ISP's
Eight External Hard Drives
Seven Java Reference Books
Six Tape Drives
Five Zip disks
Four 512Mg SIMM's
Three Floppy disks
Two LCD Monitors
and A one Gig Jump drive
On the Twelfth day of It
My true LOVE of Computers
sent to me:
Twelve Dedicated T3 Lines
Eleven E-Commerce Accounts
Ten Websites Java Driven
Nine Network ISP's
Eight External Hard Drives
Seven Java Reference Books
Six Tape Drives
Five Zip disks
Four 512Mg SIMM's
Three Floppy disks
Two LCD Monitors
and A one Gig Jump drive
but it needs to all be in the box that is created from the first part of the code. I need to build the loop display and add it to the current one each time the loop runs. I tried writing it to a file and then calling the file .. did not work. I know this is real close but I am still missing something.
Here is the code.::
public class TwelveDays {//beginning of the Class of Twelve Days
private static void showLyrics(String myLyrics) {//Class assigned box generator**********make it accessible
javax.swing.JTextArea outArea;
javax.swing.JScrollPane scroller;
outArea = new javax.swing.JTextArea(20, 35);
outArea.setText(myLyrics);
scroller = new javax.swing.JScrollPane(outArea);
javax.swing.JOptionPane.showMessageDialog(null, scroller,
"The Twelve Days of Technology",
javax.swing.JOptionPane.
INFORMATION_MESSAGE);
} //showLyrics
public static void main(String args[]) { //This is the Main Method
// print heading
System.out.println("The Twelve Days of It\n"
+ "by John H. Howard\n");
// loop through the twelve days
String toBeDisplayed = "";
for (int i = 1; i <= 12; i++) {
// print beginning of each day's verse
System.out.println("On the " + chooseDay(i) + " day of It");
System.out.println("My true LOVE of Computers\n" +
"sent to me:");
// count down through days already passed in reverse order
// if first day, final verse slightly different
// "A " vs. "and a "
// Eating my own doggie food..
if (i == 1) {
System.out.println("A " + myLyrics(i));
}
else {
for (int j = i; j >= 2; j--) {
System.out.println(myLyrics(j));
}
System.out.println("and A " + myLyrics(1));
toBeDisplayed = toBeDisplayed + "\n" + myLyrics(i);
}
// *****************Call the method
// song done, extra line
System.out.println();
}
TwelveDays.showLyrics(toBeDisplayed);
}
public static String chooseDay(int x) { //Method for the days-Case Begins
String day;
switch (x) {
case 1:
day = "First";
break;
case 2:
day = "Second";
break;
case 3:
day = "Third";
break;
case 4:
day = "Fourth";
break;
case 5:
day = "Fifth";
break;
case 6:
day = "Sixth";
break;
case 7:
day = "Seventh";
break;
case 8:
day = "Eighth";
break;
case 9:
day = "Ninth";
break;
case 10:
day = "Tenth";
break;
case 11:
day = "Eleventh";
break;
case 12:
day = "Twelfth";
break;
default:
day = "";
break;
}
return day;
}
public static String myLyrics(int x) { //Method to Reverse Order
String lyrics;
switch (x) { //Song Case list
case 1:
lyrics = "one Gig Jump drive";
break;
case 2:
lyrics = "Two LCD Monitors";
break;
case 3:
lyrics = "Three Floppy disks";
break;
case 4:
lyrics = "Four 512Mg SIMM's";
break;
case 5:
lyrics = "Five Zip disks";
break;
case 6:
lyrics = "Six Tape Drives";
break;
case 7:
lyrics = "Seven Java Reference Books";
break;
case 8:
lyrics = "Eight External Hard Drives";
break;
case 9:
lyrics = "Nine Network ISP's";
break;
case 10:
lyrics = "Ten Websites Java Driven";
break;
case 11:
lyrics = "Eleven E-Commerce Accounts";
break;
case 12:
lyrics = "Twelve Dedicated T3 Lines";
break;
default:
lyrics = "";
break;
}
return lyrics; //Reverse the Case Display
}
} //This is the end of the Twelve Days of It.
end of the code.
There does not need to be any println command. I just put those in to get my print out correct. Thought it would be easy to just move the print out to the box. Boy was I wrong.
Thanks for the help..