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.
5 1626
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 last year we got traffic of
between 2000 - 2500 unique visitors per day. We are now about to re-launch
the site from Sweden and we need to purchase a script to run it.
Having looked at what is available on the net I have realised that we need a...
|
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 parse them to have a tree representation such as :
|
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 few features that you'd expect
in any editor, except nearly none of them seem to have:
1 - Search and repalce with Regular Expressions.
2 - Search and Replace in an Xpath context.
3 - User specified tag-generation for either on 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 list class must Ioverride in order for this
to work?
| |
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 you need more detail I
can be glad to prove all my points. Our goal is to make logical systems.
We don't want php,perl, or c++ making all the procedure calls and having
the host language to be checking for errors and handleing all the...
|
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
it should look up man - find that its a function, run the man function, and
then, with that second word "something" it should then execute that as its
parameters, if that make sense.
At the moment, it semi works, i.e If i type man it will run...
|
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 download would be a plu as
well).
Here are the requirements:
|
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 Inbox
Reply
from Craig Somerford <uscos@2barter.net>
hide details 10:25 pm
(3 minutes ago)
|
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 part just explains a check digit.. i think this part in my program is alright
These barcodes actually have four parts: a tall line as the first bar, a series of
tall and short lines corresponding to the digits in the ZIP code, a check digit,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |