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.com
public class TwelveDays {//beginning of the Class of Twelve Days
private void showLyrics(String myLyrics) {//Class assigned box generator
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
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));
}
// song done, extra line
System.out.println();
}
}
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.
5 1602
Teacher did great in giving you the method. You were then supposed to call it.
Thanks the box comes up now, but now in the box only prints one line of the second case untill you press the ok button. then the next line then ok and so on. I need all the out put in the box at one time with a scroll bar and only hit ok once. The output also still prints correctly before the box appears.
Help.
Is there a way to put the output in a building array that would only generate one output? I think that needs to be the fix, but not sure.
Like an array with 12 objects
or maybe just one object that gets the new loop output added to the end and then called to the method.
Not sure what path to take. The code is real close. tring not to mess it up.
The println output is good. i just need
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
in the box that is generated by the first code.
Help..
Makes me closer but missing the heading and it is to print all twelve days in the box. With a scroll bar..
The output needs to be in a box. heading and then heading for beginning of each song and then each day . I am still having trouble.
Any help..
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Sofia |
last post by:
My name is Sofia and I have for many years been running a personals site,
together with my partner, on a non-profit basis. The site is currently not
running due to us emigrating, but during its...
|
by: Robert Maas, see http://tinyurl.com/uh3t |
last post by:
System login message says PHP is available, so I tried this:
http://www.rawbw.com/~rem/HelloPlus/h.php
It doesn't work at all. Browser just shows the source.
What am I doing wrong?
|
by: Gregory Nans |
last post by:
hello,
i need some help to 'tree-ify' a string...
for example i have strings such as :
s = """A(here 's , B(A ) silly test) C(to show D(what kind) of stuff i
need))"""
and i need to...
|
by: Mike Kamermans |
last post by:
I hope someone can help me, because what I'm going through at the moment
trying to edit XML documents is enough to make me want to never edit XML
again.
I'm looking for an XML editor that has a...
|
by: JustSomeGuy |
last post by:
I need to write an new class derived from the list class.
This class stores data in the list to the disk if an object
that is added to the list is over 1K in size.
What methods of the std stl...
|
by: Bob.Henkel |
last post by:
I write this to tell you why we won't use postgresql even though we wish we
could at a large company. Don't get me wrong I love postgresql in many
ways and for many reasons , but fact is fact. If...
|
by: Advocated |
last post by:
Hey all, thanks for taking the time to read this in the first place.
Anyway, ill try and keep it simple. In my program, if i type $ man something
it should read in the 2 words, man and something...
|
by: Gina_Marano |
last post by:
Hey All,
Ok, I give up on writing my own FTP component. Too many requirements
thrown at me after I started. (you all know how that happens ;) )
I am looking for and FTP component (http...
|
by: U S Contractors Offering Service A Non-profit |
last post by:
Brilliant technology helping those most in need Inbox
Reply
U S Contractors Offering Service A Non-profit
show details
10:37 pm (1 hour ago)
Brilliant technology helping those most in need ...
|
by: Unebrion |
last post by:
Alright im working on a program that prints out user imput in a frame, along with a barcode.. it is like the front of an envelope. Here is the description for the program.
This...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |