I have a problem. My teacher of Java is jumping all over the book and then gave us this project. Well I got the project to run. But he wants the output in a box with an ok button on it. He gave us the code and said just put it in the class and it will do the rest. Well as you guessed it does not. please look at this and let me know how to get it in the box.
Thanks John- JHHBR549@aol.co m
public class TwelveDays {//beginning of the Class of Twelve Days
private void showLyrics(Stri ng myLyrics) {//Class assigned box generator
javax.swing.JTe xtArea outArea;
javax.swing.JSc rollPane scroller;
outArea = new javax.swing.JTe xtArea(20, 35);
outArea.setText (myLyrics);
scroller = new javax.swing.JSc rollPane(outAre a);
javax.swing.JOp tionPane.showMe ssageDialog(nul l, scroller,
"The Twelve Days of Technology",
javax.swing.JOp tionPane.
INFORMATION_MES SAGE);
} //showLyrics
public static void main(String args[]) { //This is the Main Method
// print heading
System.out.prin tln("The Twelve Days of It\n"
+ "by John H. Howard\n");
// loop through the twelve days
for (int i = 1; i <= 12; i++) {
// print beginning of each day's verse
System.out.prin tln("On the " + chooseDay(i) + " day of It");
System.out.prin tln("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.prin tln("A " + myLyrics(i));
}
else {
for (int j = i; j >= 2; j--) {
System.out.prin tln(myLyrics(j) );
}
System.out.prin tln("and A " + myLyrics(1));
}
// song done, extra line
System.out.prin tln();
}
}
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.
Thanks John- JHHBR549@aol.co m
public class TwelveDays {//beginning of the Class of Twelve Days
private void showLyrics(Stri ng myLyrics) {//Class assigned box generator
javax.swing.JTe xtArea outArea;
javax.swing.JSc rollPane scroller;
outArea = new javax.swing.JTe xtArea(20, 35);
outArea.setText (myLyrics);
scroller = new javax.swing.JSc rollPane(outAre a);
javax.swing.JOp tionPane.showMe ssageDialog(nul l, scroller,
"The Twelve Days of Technology",
javax.swing.JOp tionPane.
INFORMATION_MES SAGE);
} //showLyrics
public static void main(String args[]) { //This is the Main Method
// print heading
System.out.prin tln("The Twelve Days of It\n"
+ "by John H. Howard\n");
// loop through the twelve days
for (int i = 1; i <= 12; i++) {
// print beginning of each day's verse
System.out.prin tln("On the " + chooseDay(i) + " day of It");
System.out.prin tln("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.prin tln("A " + myLyrics(i));
}
else {
for (int j = i; j >= 2; j--) {
System.out.prin tln(myLyrics(j) );
}
System.out.prin tln("and A " + myLyrics(1));
}
// song done, extra line
System.out.prin tln();
}
}
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.
Comment