JOptionPane help please - I'd be v. grateful

Hi,
Can you help me please? I'm just learning Java and was curious if it's possible to change the font color of text in a MessageDialog?
For example, if I was saying something like
JoptionPane.showMessageDialog(null,
"\n I have 2 cats" +
"\n I have 1 dog" +
"\n I have 3 budgerigars" +
"\n" +
"\n I have " + numberOfPets + " pets", JOptionPane.INFORMATION_MESSAGE)How do I change the last line for example to be in red and perhaps bold?
Also for the lines above the last line, I wanted to indent these but if I try "\t" after the "\n", it does not work.
Can somebody help me please?
Many thanks
Edited by: steveb on Nov 6, 2007 10:50 AM

If you are new to Java, you shouldn't be worrying about little tweaks like this -- concentrate on learning object-oriented concepts.
Anyway, the message string can include some html markup:
String msg = "<html>foo <i>bar</i> <font color='green'>baz</font></html>";
JOptionPane.showMessageDialog(null,msg);

Similar Messages

  • InputVerifier and JOptionPane help please

    I am trying to create an application and require to validate input fields. I have successfully written the code to use the InputVerifier class to validate the input but want to use a JOptionPane dialog to notify errors. This doesn't seem to work as the JOption Pane is treated as an attempt to shift focus from the field being validated (which calls shouldYieldFocus() which tries to show a JOptionPane which tries to shift focus .........). I have a temporary fix by using an disabled text field to display the message but it isn't very elegant. Anyone any ideas please ?

    Did you get any solution?
    I am also facing the same problem but with Jdk 1.4 only.
    In Jdk 1.3 it's working fine.
    Please let me know if u have any solution

  • 'Error loading plugin: Plugin file not found' message on ONLY 5 sites, but all others OK.  Help, please!

    Hi Again!
    I posted this problem here before, but since I really need to access the sites that receive this error message in less than a month, I had to re-post; hopefully someone who didn't see it before will see it & have a solution for me.
    Here are the details:  I'm running windows 8.1 & I use Firefox 33.1.1, Pale Moon 25.1.0 or Opera 26.0 as my browsers, (I have IE installed & up-to-date, but I never use it).  I followed the 10-point checklist on Adobe & everything was done, except for "uncheck Hardware Acceleration" in Flash 'Settings'; I tried to uncheck it on this site, where it's indicated, as well as in my 4 browsers when I'm doing something that uses Flash, but no matter how hard I try, I can't 'uncheck' the check mark in that tiny box!  Since this error problem only affects 5 web sites, & I can watch streaming media on all other sites, I don't think it's an issue. 
    Here's how this problem began:  I was watching a live, streaming nest-cam on 5/09/14 around 11:00AM, (yes, I DO know the exact time & date, because it happened so suddenly while I was watching this website that I'd been watching since the end of February, 2014), when my screen went black.  I thought it was probably an Adobe Crash, but when the usual Crash Report window didn't show up, I just closed Firefox & reopened it, expecting to resume watching the nest-cam.  When I went back to the site, I got the black screen with the "Error loading plugin: Plugin file not found" message.  The chat portion on the site still works, though. I know there are other sites with this nest-cam feed, so I started trying them, but it took several tries for me to find one that didn't get the error message! I posted this problem on "Windows BBS" forum, & someone else posted that the same thing happened to them AND on the same sites!  They didn't have a solution, either.  I cleared my cache, rebooted my PC & even did a System Restore, but whatever happened in that brief second made using ONLY 5 sites impossible.  Here are the sites that receive the error message:
    http://pixcontroller.com/eagles, (but I CAN go to http://pixcontroller.com, but there isn't any streaming media)
    http://cbslocal.com/eagles
    http://westmorelandconservancy.org/BlueBirdwebcam-1.htm
    http://wildearth.tv/cam/pittsburgh-bald-eagles, (I get the error message on ALL cams on this site)
    http://aviary.org/BE-NestCam1 (I get the error message on ALL cams on this site)
    Now if any videos from the 5 websites above are uploaded to YouTube, I can watch them perfectly...no error message if I watch the videos elsewhere.  Luckily, I found Ustream, & they have most of the nest cams I watch, but I need to fix this issue, because it's nearing nesting time!  I'm an amateur nest-watcher & it's vital that I have access to these 5 sites, so if anyone knows how to fix this, PLEASE tell me!
    Thanks for taking the time to read my post.
    All suggestions/solutions are gratefully accepted.
    Thanks in advance for your help!
    DogPal 

    File Not Found Error in Welcome Screen
    07-Nov-2013 10:25
    Tags: #dreamweaver_cs6_update
    Help please!
    Live preview also not working.
    I have exactly the exact problem described below but do not have a folder with the same name as the volume created under the volume. Please can someone help - I've tried everything. This problem only happened when I upgraded to Dreaweaver CC!
    "On launching Dreamweaver on your Macintosh if your Welcome Screen is not loading and if you see a "File not found" error, please check if you have a folder with the same name as your volume created under the volume. For more info on this please go through the attached pdf document. Other dialogs/panels in dreamweaver that will be blank due to this issue are Jquery Swatches panel, Adobe Edge Webfonts tab in Manage Fonts dialog,W3c Error Info dialog, Externalise Javascript dialog and svn revert dialog. After following the changes mentioned in the attached document please check all the affected dialogs/panels to confirm everything is working as expected."
    Thanks,
    Martin Bond
    [personal information removed by moderator]

  • Can't get into IPad 2 after latest update.  HELP, PLEASE!??

    I made the mistake of updating my IPad 2 to the latest IOS7.  Now I cannot get into it.  When I turn it on, it says 'hello' and to swipe to set up the new update.  Sometimes the swipe brings up a new screen; sometimes it just scrolls through several languages.  Sometimes it asks for my Apple ID and gets as far as "updating ICloud."  It NEVER finishes updating ICloud! 
    I cannot reach my apps or a normal looking screen.  Can someone help, please?  Is there any way to get this update to work or to UNDO the update?  I'll be grateful if you can help.......  Thank you so much!
    Virginia

    1. Slide to set up
    2. Select language
    3. Select country/region
    4. Choose Wi-Fi Network
    5. Enable/Disable Location Service
    6. Enter Apple ID and Password
    7. (a) Set Up as New (b) Restore from iCloud Backup (c) Restore from iTune Backup
    8. Terms and Conditions
    9. Use iCloud/Don't use iCloud
    10. Create/Don't create Passcode
    11. Diagnostics
    12. Welcome to iPad

  • Can't Left Click in Flash Player Settings Panel - HELP PLEASE

    Hi and thanks for taking the time to read this. Believe me it is a fraction of the time I have wasted trying to resolve this issue.
    Basic problem is:
    I am trying to stream to Ustream but since downloading AFP11 for my Windows PC when I open the Flash Player Settings panel i can't left click on anything. It is set to deny but I can't click allow, or close or any of the icons.
    Right click does work.
    I have followed countless instructions in other forums from other posts that have encountered the problem on Mac and older versions of AFP but as yet none of the solutions have proven succesul.
    I have tried all of the following but nothing has resolved the problem.
    1. Uninstall and reinstall Adobe Flash Player (although this is impossible using Google Chrome) and restart computer.
    2. Unistall flash and install older version. (made no difference on Google Chrome and on IE8 had no flash whatsoever).
    5. Uninstall older AFP and reinstall AFP11.
    4. Uninstall Google Chrome and restart computer.
    5. Uninstall QuickTime (I got this off http://www.techsupportforum.com/forums/f10/flash-player-not-working-properly-please-help-1 61552.html) and restart computer
    6. Last resort use keyboard shortcuts such as tab, enter and ctrl+arrows. This either didn't highlight the panel at all or if it did I still couln't select allow, or close the panel itself so was no help either.
    So now I'm back to square one.
    Now here's a really bizarre thing... I am using a shared laptop computer and if I use my colleagues profile where she hasn't updated her AFP to Adobe Flash Player 11 the settings panel is responding just fine. IT'S THE SAME PC!
    I know I am alone with this problem but someone out there has an answer. If you can help please let me know how to fix this problem where I can't left click in the Adobe Flash Player settings panel.and I will be eternily grateful.
    many thanks
    nik

    OK the amount I hate myself right now is more than a fat guy's self loathing for raiding the fridge at 2am for Pizza but less than an armed robber who's accidentally shot a pregnant woman in the stomach during a shootout. but not much less.
    So after I had miraculously got the Flash Player Setting Panel to work again, (after deleting QuickTime and leaving the window open for abut an hour it just started working again) I then got enticed into downloading the ustream producer software.
    While downloading it informed me that it would only work with QuickTime.
    Stupidly and Optimistically hoping it would remove the need to use flash player altogether I downloaded and installed both.
    I then discovered to my horror that Ustream producer is not a patch on Vidbalster and that it was not capable of delivering the same level of broadcast.
    I then opened the flash player settings panel on ustream and... the problem has returned!
    This means I am 99% sure that QuickTime IS the cause of the problem so I have uninstalled QT off the PC. I have also uninstalled Ustream Producer.
    The thing is though, now no matter how many times I restart, or uninstall and reinstall Adobe, or Google Chrome, I am once again UNABLE TO LEFT CLICK IN THE FLASH PLAYER SETTINGS PANEL. AAAARRRRRGGGGHHHH!!!!
    What did I do? I fixed it and  f***ing broke it again!
    Now it properly will not come back to life! the problem is not solved and i urgently need help.
    Why does Adobe Flash Player Settings Panel and Apple QuickTime hate each other so much that they've got to ruin my life?
    Help forum PLEASE!
    Regards,
    nik

  • I'm new to java and need help please

    I have an assignment involves modifying a previous assignment. the code for the previous assigment is shown below.(it was required to be done as an applet this assigment can be an application or an applet) I'm trying to modify this code to read a text file (items.txt) that looks like this:
    item # description price(this line does not appear in the text file)
    001 shaving cream 400.00
    999 razors 30.00
    I need to load the item# and price from the text file into arrays(I have no clue how to use multi-dimensional arrays in java and would prefer not to)
    I need to search the arrays based on the values entered by the user (item # and quantity) calculate the total for that item then create a new text file which has each line item for that order in the form:
    item# quant price per item total(price per item*quant entered)
    also also I need to be able to display the four items listed above after each loop as well as all the previous item number and quantities they selected until they indicate they don't want to select anymore.
    I've been working on this for days and it seems like nothing I try works. My major problems are:
    1. I have no idea how to read the text file and load those 2 items into their respective arrays
    2. I can't seem to create a textfile that looks like text for the output file.
    code]
    import java.io.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.text.*;
    import java.util.Locale;
    public class arraySelection
    extends JApplet {
    //Initialize the applet
    private Container getContentPane=null;
    public void init() {
    String string_item, string_quantity;
    String output = "";
    String description= "";
    int counter= 0;
    int itemNumber= 0;
    double quantity = 0 ;
    double tax_rate=.07;
    double total= 0, price= 0;
    double tax, subtotal;
    double Pretotal= 0;
    double priceArray[] = {1, .5, 3.65, 0.02, 0.09};
    String descriptionArray[] = {"salt", "pepper", "paprika", "garlic", "thyme"};
    // create number format for currency in US dollar format
    NumberFormat moneyFormat = NumberFormat.getCurrencyInstance( Locale.US );
    //format to have the total with two digits precision
    DecimalFormat twoDigits = new DecimalFormat("0.00");
    //Jtextarea to display results
    JTextArea outputArea = new JTextArea ();
    // get applet's content pane
    Container container = getContentPane ();
    //attach output area to container
    container.add(outputArea);
    //set the first row of text for the output area
    output += "Invoice\nItem#\tDescription\tQuant@Price\t Line Total" + "\n";
    do //begin loop structure obtain input from user
    // obtain item number from user
    string_item = JOptionPane.showInputDialog(
    "Please enter an item number 1, 2, 3, 4, or 5:");
    //obtain quantity of each item that user enter
    string_quantity = JOptionPane.showInputDialog("Enter the quantity:");
    // convert numbers from type String to Integer or Double
    itemNumber = Integer.parseInt(string_item);
    quantity = Double.parseDouble(string_quantity);
    switch (itemNumber) {//Determine input from user to assign price and description
    case 10: // user input item =10
    price = priceArray[0];
    description = descriptionArray[0];
    break;
    case 20: // user input item =20
    price = priceArray [1];
    description = descriptionArray[1];
    break;
    case 30: //user input item =30
    price=priceArray[2];
    description = descriptionArray[2];
    break;
    case 40: //user input item =40
    price=priceArray[3];
    description = descriptionArray[3];
    break;
    case 50: //user input item =50
    price=priceArray[4];
    description = descriptionArray[4];
    break;
    default: // user input item is not on the list
    output += "Invalid value entered"+ "\n";
    price=0;
    description= "";
    //Calculates the total for each item number and stores it in subtotal
    subtotal = price * quantity;
    //display input from user
    output += itemNumber + "\t" + description + "\t\t"+ quantity + "@" +
    moneyFormat.format( price) + "\t" + moneyFormat.format( subtotal) + "\n";
    //accumulates the overall subtotal for all items
    Pretotal = Pretotal + subtotal;
    //verifies that the user wants to stop entering data
    string_item = JOptionPane.showInputDialog(" Enter a positive integer to continue or 0 to stop. ");
    itemNumber = Integer.parseInt(string_item);
    // loop termination condition if user's input is 0 .It will end the loop
    } while ( itemNumber!= 0);
    tax = Pretotal * tax_rate; // calculate tax amount
    total = Pretotal + tax; //calculate total = subtotal + tax
    //appends data regarding the subtotal, tax, and total to the output area
    output += "\n" + "Order Subtotal" + "\t" + moneyFormat.format( Pretotal) +
    "\n" + "Tax" + "\t\t" + twoDigits.format( tax ) + "\n" + "Order Total" +
    "\t\t" + moneyFormat.format( total );
    //attaches the data in the output variable to the output area
    outputArea.setText( output );
    } //end init
    }// end applet Invoice
    Any help or sugestions would be greatly appreaciated. I've been working on this for over a week and everything I try goes nowhere.

    item # description price(this
    line does not appear in the text file)
    001 shaving cream 400.00
    999 razors 30.00
    I need to load the item# and price from the text file
    into arrays(I have no clue how to use
    multi-dimensional arrays in java and would prefer not
    to)That's good, because you shouldn't use multidimensional arrays here. You should have a one-dimensional array (or java.util.List) of objects that encapsulate each line.
    I've been working on this for days and it seems like
    nothing I try works. My major problems are:
    1. I have no idea how to read the text file and load
    those 2 items into their respective arrays
    2. I can't seem to create a textfile that looks like
    text for the output file.The java.io package has file reading/writing classes.
    Here's a tutorial:
    http://java.sun.com/docs/books/tutorial/essential/io/index.html

  • I'm new to java and need help please(repost)

    I have an assignment involves modifying a previous assignment. the code for the previous assigment is shown below.(it was required to be done as an applet this assigment can be an application or an applet) I'm trying to modify this code to read a text file (items.txt) that looks like this:
    item # description price(this line does not appear in the text file)
    001 shaving cream 400.00
    999 razors 30.00
    I need to load the item# and price from the text file into arrays(I have no clue how to use multi-dimensional arrays in java and would prefer not to)
    I need to search the arrays based on the values entered by the user (item # and quantity) calculate the total for that item then create a new text file which has each line item for that order in the form:
    item# quant price per item total(price per item*quant entered)
    also also I need to be able to display the four items listed above after each loop as well as all the previous item number and quantities they selected until they indicate they don't want to select anymore.
    I've been working on this for days and it seems like nothing I try works. My major problems are:
    1. I have no idea how to read the text file and load those 2 items into their respective arrays
    2. I can't seem to create a textfile that looks like text for the output file.
    import java.io.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.text.*;
    import java.util.Locale;
    public class arraySelection
        extends JApplet {
      //Initialize the applet
      private Container getContentPane=null;
      public void init() {
           String string_item, string_quantity;
           String output = "";
           String description= "";
           int counter= 0;
           int itemNumber= 0;
           double quantity = 0 ;
           double tax_rate=.07;
           double total= 0, price= 0;
           double tax, subtotal;
           double Pretotal= 0;
           double priceArray[] = {1, .5, 3.65, 0.02, 0.09};
           String descriptionArray[] = {"salt", "pepper", "paprika", "garlic", "thyme"};
         // create number format for currency in US dollar format
         NumberFormat moneyFormat = NumberFormat.getCurrencyInstance( Locale.US );
         //format to have the total with two digits precision
         DecimalFormat twoDigits = new DecimalFormat("0.00");
         //Jtextarea to display results
         JTextArea outputArea = new JTextArea ();
         // get applet's content pane
          Container container = getContentPane ();
          //attach output area to container
          container.add(outputArea);
         //set the first row of text for the output area
        output +=  "Invoice\nItem#\tDescription\tQuant@Price\t Line Total" + "\n";
        do //begin loop structure obtain input from user
               // obtain item number from user
               string_item = JOptionPane.showInputDialog(
                   "Please enter an item number 1, 2, 3, 4, or 5:");
               //obtain quantity of each item that user enter
               string_quantity = JOptionPane.showInputDialog("Enter the quantity:");
               // convert numbers from type String to Integer or Double
               itemNumber = Integer.parseInt(string_item);
               quantity = Double.parseDouble(string_quantity);
                 switch (itemNumber) {//Determine input from user to assign price and description
                    case 10: // user input item =10
                      price = priceArray[0];
                      description = descriptionArray[0];
                      break;
                    case 20: // user input item =20
                      price = priceArray [1];
                      description = descriptionArray[1];
                      break;
                    case 30: //user input item =30
                      price=priceArray[2];
                      description = descriptionArray[2];
                      break;
                    case 40: //user input item =40
                      price=priceArray[3];
                      description = descriptionArray[3];
                      break;
                    case 50: //user input item =50
                      price=priceArray[4];
                      description = descriptionArray[4];
                      break;
                    default: // user input item is not on the list
                    output += "Invalid value entered"+ "\n";
                    price=0;
                    description= "";
             //Calculates the total for each item number and stores it in subtotal
             subtotal = price * quantity;
             //display input from user
             output += itemNumber + "\t" + description + "\t\t"+ quantity + "@" +
                       moneyFormat.format( price) + "\t" + moneyFormat.format( subtotal) + "\n";
             //accumulates the overall subtotal for all items
             Pretotal = Pretotal + subtotal;
            //verifies that the user wants to stop entering data
            string_item = JOptionPane.showInputDialog(" Enter a positive integer to continue or 0 to stop. ");
            itemNumber = Integer.parseInt(string_item);
          // loop termination condition if user's input is 0 .It will end the loop
       } while ( itemNumber!= 0);
        tax = Pretotal * tax_rate; // calculate tax amount
        total = Pretotal + tax; //calculate total = subtotal + tax
        //appends data regarding the subtotal, tax, and total to the output area
        output += "\n" + "Order Subtotal" + "\t" + moneyFormat.format( Pretotal) +
                  "\n" + "Tax" + "\t\t" + twoDigits.format( tax ) + "\n" + "Order Total" +
                  "\t\t" + moneyFormat.format( total );
         //attaches the data in the output variable to the output area
         outputArea.setText( output );
      } //end init
    }// end applet InvoiceAny help or sugestions would be greatly appreaciated. I've been working on this for over a week and everything I try goes nowhere.

    First answer: You shouldn't ask multiple questions in the same thread. Ask a specific question, with an appropriate subject line (optionally, assign the number of Dukes you are willing to give for the help). When question #1 is answered and question #2 arises, it's time for a new thread (don't forget to give out Dukes before moving on).
    Second answer: I think you need a Transfer Object (http://java.sun.com/blueprints/patterns/TransferObject.html). It's whole purpose is to hold/transfer instance data where it is needed. Create a class something like this:
    public class ItemTO
        private String _number;
        private String _description;
        private double _price;
        public ItemTO( String number, String description, double price )
            _number = number;
            _description = description;
            _price = price
        // Getter/Setter methods go here
    }then, in the code where you read in the file do something like this:
    BufferedReader input = null;
    try
        input  = new BufferedReader( new FileReader( "c:\\a.txt" ) );
        List items = new ArrayList();
        String line;
        String itemNumber;
        String itemDescription;
        double itemPrice;
        while ( (line  = input.readLine() ) != null )
         System.out.println( line );
            itemNumber = // Parse it from line
            itemDescription // Parse it from line
            itemPrice = // Parse it from line
            items.add( new ItemTO( itemNumber, itemDescription, itemPrice ) );
    catch ( FileNotFoundException fnfe )
        fnfe.printStackTrace();
    catch ( IOException ioe )
        ioe.printStackTrace();
    finally
        try
            if ( input != null )
                input.close();
        catch ( Exception e )
            e.printStackTrace();
    }As for how to parse the line of the file, I'll leave that to you for now. Are the three values delimited with any special characters?
    jbisotti

  • DEP Print Crash (Reader 9.3.2) - Help please?

    Help please anyone?
    Window DEP (Deta Execution Protection) stops me printing pdfs and the print crashes.
    If I tick/check DEP to allow me to use Reader 9 that makes NO difference even though it says if should.
    I'm using Reader 9.3.2 - not an earlier version - and the print crash happens either in Reader, using it alone, or when I open a pdf in IE or Firefox.
    I am running XP SP3, recently updated from SP2   (there maybe a connecton - was it the XP3 update which did it?)
    This is very frustrating. I don't want to abandon Adobe Reader and use a different company's  program but I have wasted hours so far tring to find a fix for this.
    Incidentally fiddling with Javascript [Reader>Edit>Preferences>Untick Enable Acrobat JavaScript] which is one recommended fix whichdoesn't work.
    Maybe there any other files I can get DEP to ignore? (NB they all have to be .exe files so be sure to tell me where to find them!)
    All advice gratefully received. I am SOooo fed up with this.
    Thanks!

    All I know is that I can't print from Adobe Reader any more but I can print pdfs since I replaced it with Foxit Reader.
    I suspect this is maybe connected with my XP upgrade from SP2 to SP3.
    I knew it might mess things up and this happened soon after. I also can't print AT ALL from Firefox now and that happened at the same time too.
    Microsoft again....? Who knows. I have solved my pdf printing problem a roundabout way, but not my Firefox problem - tho that isn't for this forum!

  • Help please no luck recording vinyl thru line-in port on External USB Soundblaster Live 24bit

    Help please! I have connected LP turntable (I am assured which has preamp inbuilt) to line-in port on S/Blaster external using lead inbuilt from?turntable with white/red RCA plugs with a line -in plug converter. Then connected external soundcard?to the notebook USB-USB as per manual. I have tried Creative's Smart Recorder but it shows no sound coming through on Analysis (same with Audiograbber software too). Sound card diagnostics show sound card OK and I can plug in headphones and get output. I am thinking hardware connection issue as I connected direct from turntable to microphone input &?got loud mike low quality recording but I ustand this is not recommended as can blow sound card (and poor receording anyway)?Is there another device I can easily plug into line in to test - or any other ideas gratefully received.

    hardingt2345 wrote:
    Help please! I have connected LP turntable (I am assured which has preamp inbuilt) to line-in port on S/Blaster external using lead inbuilt from?turntable with white/red RCA plugs with a line -in plug converter. Then connected external soundcard?to the notebook USB-USB as per manual. I have tried Creative's Smart Recorder but it shows no sound coming through on Analysis (same with Audiograbber software too). Sound card diagnostics show sound card OK and I can plug in headphones and get output. I am thinking hardware connection issue as I connected direct from turntable to microphone input &?got loud mike low quality recording but I ustand this is not recommended as can blow sound card (and poor receording anyway)?Is there another device I can easily plug into line in to test - or any other ideas gratefully received.
    Have you tried by installing www.asio4all.com drivers and then by using some?ASIO capable recording software as like Kristal, VSTHost, Reaper, etc (there are many others available)?jutapa

  • Need quick help please!! Fast!

    Here is my code... I know it's long, but it's simple. The only part I'm having trouble with is the very end. You don't really have to know what point of this to help me figure out the problem. Near the very bottom, you'll see the line "double refund = (startcancount/startendcount)*premium;". For some reason, this keeps coming out as zero, even though I run it through the debugger and every single one of the variables has a non-zero value. I cannot figure it out. I tried changing the data type to float to no avail. What is the problem!?
    package isys202p1;
    import javax.swing.JOptionPane;
    public class ISys202P1 {
         public static void main(String[] args) {
              //Initialized variables for storing the string values of the entered names, premium
              String firstname;
              String middlename;
              String lastname;
              String response = null;
              double premium = 0;
              int startyear = 0;
              int startmonth = 0;
              int startday = 0;
              int endyear = 0;
              int endmonth = 0;
              int endday = 0;
              int canyear = 0;
              int canmonth = 0;
              int canday = 0;
              int startendcount = 0;
              int startcancount = 0;
              String ssmonth = null;
              String esmonth = null;
              String csmonth = null;
              //Prompts user for first name and stores it in the string variable firstname
              firstname = JOptionPane.showInputDialog("Please enter your first name:");
              //Prompts user for middle name and stores it in the string variable middlename
              middlename = JOptionPane.showInputDialog("Please enter your middle name");
              //Prompts user for last name and stores it in the string variable lastname
              lastname = JOptionPane.showInputDialog("Please enter your last name:");
              //Prompts the user for a premium amount, without the dollar sign, and assigns to the premium variable
              response = JOptionPane.showInputDialog("Please enter your premium amount: $");
                   premium = Double.parseDouble(response);
              //Prompts the user for the starting date of the policy term (year)
              response = JOptionPane.showInputDialog("Please enter the starting date for the policy term (year)");
                   startyear = Integer.parseInt(response);
              //Prompts the user for the starting date of the policy term (month)
              response = JOptionPane.showInputDialog("Please enter the starting date for the policy term (month)");
                   startmonth = Integer.parseInt(response);
              //Prompts the user for the starting date of the policy term (day)
              response = JOptionPane.showInputDialog("Please enter the starting date for the policy term (day)");
                   startday = Integer.parseInt(response);
              //Prompts the user for the ending date of the policy term (year)     
              response = JOptionPane.showInputDialog("Please enter the ending date for the policy term (year)");
                   endyear = Integer.parseInt(response);
              //Prompts the user for the ending date of the policy term (month)
              response = JOptionPane.showInputDialog("Please enter the ending date for the policy term (month)");
                   endmonth = Integer.parseInt(response);
              //Prompts the user for the ending date of the policy term (day)          
              response = JOptionPane.showInputDialog("Please enter the ending date for the policy term (day)");
                   endday = Integer.parseInt(response);
              //Prompts the user for the effective date of the policy cancellation (year)
              response = JOptionPane.showInputDialog("Please enter the effective date for the policy cancellation (year)");
                   canyear = Integer.parseInt(response);
              //Prompts the user for the effective date of the policy cancellation (month)
              response = JOptionPane.showInputDialog("Please enter the effective date for the policy cancellation (month)");
                   canmonth = Integer.parseInt(response);
              //Prompts the user for the effective date of the policy cancellation (day)
              response = JOptionPane.showInputDialog("Please enter the effective date for the policy cancellation (day)");
                   canday = Integer.parseInt(response);
                   //if statements that account for mid-year starting dates
              if (startmonth==1)
                   startcancount=0+startday;
              if (startmonth==2)
                   startcancount=31+startday;
              if (startmonth==3)
                   startcancount=59+startday;
              if (startmonth==4)
                   startcancount=90+startday;
              if (startmonth==5)
                   startcancount=120+startday;
              if (startmonth==6)
                   startcancount=151+startday;
              if (startmonth==7)
                   startcancount=181+startday;
              if (startmonth==8)
                   startcancount=212+startday;
              if (startmonth==9)
                   startcancount=243+startday;
              if (startmonth==10)
                   startcancount=274+startday;
              if (startmonth==11)
                   startcancount=304+startday;
              if (startmonth==12)
                   startcancount=335+startday;
                   //if statements that account for mid-year ending dates
              if (canmonth==1)
                   startcancount=startcancount+canday;
              if (canmonth==2)
                   startcancount=startcancount+31+canday;
              if (canmonth==3)
                   startcancount=startcancount+59+canday;
              if (canmonth==4)
                   startcancount=startcancount+90+canday;
              if (canmonth==5)
                   startcancount=startcancount+120+canday;
              if (canmonth==6)
                   startcancount=startcancount+151+canday;
              if (canmonth==7)
                   startcancount=startcancount+181+canday;
              if (canmonth==8)
                   startcancount=startcancount+212+canday;
              if (canmonth==9)
                   startcancount=startcancount+243+canday;
              if (canmonth==10)
                   startcancount=startcancount+274+canday;
              if (canmonth==11)
                   startcancount=startcancount+304+canday;
              if (canmonth==12)
                   startcancount=startcancount+335+canday;
                   //if statements that account for mid-year starting dates
              if (startmonth==1)
                   startendcount=0+startday;
              if (startmonth==2)
                   startendcount=31+startday;
              if (startmonth==3)
                   startendcount=59+startday;
              if (startmonth==4)
                   startendcount=90+startday;
              if (startmonth==5)
                   startendcount=120+startday;
              if (startmonth==6)
                   startendcount=151+startday;
              if (startmonth==7)
                   startendcount=181+startday;
              if (startmonth==8)
                   startendcount=212+startday;
              if (startmonth==9)
                   startendcount=243+startday;
              if (startmonth==10)
                   startendcount=274+startday;
              if (startmonth==11)
                   startendcount=304+startday;
              if (startmonth==12)
                   startendcount=335+startday;
              //if statements that account for mid-year ending dates
              if (endmonth==1)
                   startendcount=startendcount+endday;
              if (endmonth==2)
                   startendcount=startendcount+31+endday;
              if (endmonth==3)
                   startendcount=startendcount+59+endday;
              if (endmonth==4)
                   startendcount=startendcount+90+endday;
              if (endmonth==5)
                   startendcount=startendcount+120+endday;
              if (endmonth==6)
                   startendcount=startendcount+151+endday;
              if (endmonth==7)
                   startendcount=startendcount+181+endday;
              if (endmonth==8)
                   startendcount=startendcount+212+endday;
              if (endmonth==9)
                   startendcount=startendcount+243+endday;
              if (endmonth==10)
                   startendcount=startendcount+274+endday;
              if (endmonth==11)
                   startendcount=startendcount+304+endday;
              if (endmonth==12)
                   startendcount=startendcount+335+endday;
              //for loop that counts the days between the beginning and end of the policy
              for (int startcount = startyear; startcount < canyear; startcount++){
                   startcancount = startcancount + 365;
                   if (((startcount%4==0) & (startcount%100!=0)) | ((startcount%400==1) & (startcount%100==0))){
                        startcancount = startcancount + 1;
              for (int startcount = startyear; startcount < endyear; startcount++){
                   startendcount = startendcount + 365;
                   if (((startcount%4==0) & (startcount%100!=0)) | ((startcount%400==1) & (startcount%100==0))){
                        startendcount = startendcount + 1;
              //[Start String Month] Assigns the number for starting month entered to its corresponding month (starting date)
              if (startmonth == 1)
                   ssmonth = "January";
              if (startmonth == 2)
                   ssmonth = "February";
              if (startmonth == 3)
                   ssmonth = "March";
              if (startmonth == 4)
                   ssmonth = "April";
              if (startmonth == 5)
                   ssmonth = "May";
              if (startmonth == 6)
                   ssmonth = "June";
              if (startmonth == 7)
                   ssmonth = "July";
              if (startmonth == 8)
                   ssmonth = "August";
              if (startmonth == 9)
                   ssmonth = "September";
              if (startmonth == 10)
                   ssmonth = "October";
              if (startmonth == 11)
                   ssmonth = "November";
              if (startmonth == 12)
                   ssmonth = "December";
              //[cancellation string month]Assigns the number for ending month entered to its corresponding
              //month (cancellation effective date)
              if (canmonth == 1)
                   csmonth = "January";
              if (canmonth == 2)
                   csmonth = "February";
              if (canmonth == 3)
                   csmonth = "March";
              if (canmonth == 4)
                   csmonth = "April";
              if (canmonth == 5)
                   csmonth = "May";
              if (canmonth == 6)
                   csmonth = "June";
              if (canmonth == 7)
                   csmonth = "July";
              if (canmonth == 8)
                   csmonth = "August";
              if (canmonth == 9)
                   csmonth = "September";
              if (canmonth == 10)
                   csmonth = "October";
              if (canmonth == 11)
                   csmonth = "November";
              if (canmonth == 12)
                   csmonth = "December";
    //Assigns the number for ending month entered to its corresponding month (ending date)
              if (endmonth == 1)
                   esmonth = "January";
              if (endmonth == 2)
                   esmonth = "February";
              if (endmonth == 3)
                   esmonth = "March";
              if (endmonth == 4)
                   esmonth = "April";
              if (endmonth == 5)
                   esmonth = "May";
              if (startmonth == 6)
                   ssmonth = "June";
              if (endmonth == 7)
                   esmonth = "July";
              if (endmonth == 8)
                   esmonth = "August";
              if (endmonth == 9)
                   esmonth = "September";
              if (endmonth == 10)
                   esmonth = "October";
              if (endmonth == 11)
                   esmonth = "November";
              if (endmonth == 12)
                   esmonth = "December";
              double refund = (startcancount/startendcount)*premium;
              //The final output consisting of the users first name, middle name, and last name.
              JOptionPane.showMessageDialog(null, "Name: " + firstname + " " + middlename + " " + lastname + "\n" +
                        "Premium: $" + premium + "\n" + "Date: " + ssmonth + " " + startday + ", " + startyear + "\n" +
                        "End Date: " + esmonth + " " + endday + ", " + endyear + "\n" + "Effective Date: " + csmonth +
                        " " + canday + ", " + canyear + "\n" + "Refund: " + refund);
    }

    DeLorean wrote:
    If I want the program to repeat itself (except for entering the names), how would I do it using a for loop? Could someone edit my code to show me?Why don't you try it yourself?
    If you have tried, but failed to get it working, then you can post back here. Be sure that when asking a question here, the chances in getting helpful answers increase dramatically when you:
    - show what you have already tried;
    - post code using code tags;
    - use a meaningful title for your question;
    - DONT try to hurry those who are able to help you with words like "fast", "asap", "urgent", etc.

  • I use Microsoft XP on my PC, where r my pictures from my iPad? I need to know how to send pictures to Walgreens, etc so I can get them printed. Help please!

    I use Microsoft XP on my PC, where r my pictures from my iPad? I need to know how to send pictures to Walgreens, etc so I can get them printed. Help please!

    I am legally blonde and not very tech savvy, so I don't really know how to do that.  I know ur time is valuable, so could u possibly give me a short tutorial?  I would b very grateful! I use the camera kit to get my pics from my sd card to my iPad and also from my iPhone to my iPad. Had I known I would have this problem, I would not have transferred my pics to my iPad until after I took the sd card and had my pics printed.

  • "HiLo" number guessing game not working - Help please!

    My game is compiling and read's right (in my head) but doesn't appear to work, any help is highly appreciated, thank you.
    Source code. More specifically, I think that it's properly getting the random number, but the guess prompt is not appearing, probably because of my while(random!=number) line?
    import javax.swing.JOptionPane;
    import java.util.Random;
    * High-Low (HiLo) game.
    * @author
    * @version 11/18/2010
    public class HiLo
        String randomNumber = "";
        int random;
        String userNum = "";
        int number;
         * Asks player if he wants to play, gets random number, gets user guess, checks the users guess, asks to repeat.
        public void play()
            getRandom();
            while(random!=number)
                getGuess();
                checkGuess();
         * Gets the users guess.
        public int getGuess()
            userNum = JOptionPane.showInputDialog ("Please Guess the number");
            int number = Integer.parseInt(userNum);
            return number;
         * Gets a random number between 0 and 100
         * int named random
        public int getRandom()
            Random randomNumber = new Random();
            int random = randomNumber.nextInt(101);
            return random;
         * Checks to see if the user's guess is an integer, between 0 and 100, and returns if
         * they're guess is too high or too low.
        public void checkGuess()
            if (number==random)
                JOptionPane.showMessageDialog(null, "You Win!");
            else if (number<random)
                JOptionPane.showMessageDialog(null, "Too low, guess again!");
            else if (number>random)
                JOptionPane.showMessageDialog(null, "Too high, guess again!");
    }Edited by: 811146 on Nov 18, 2010 3:11 PM

    Sorry about that Darryl,
    a few more questions on this code though.
    1.How can I have my getGuess() only accept integers?
    here it is now:
    public int getGuess()
            userNum = JOptionPane.showInputDialog ("Guess a number between 0 and 100");
            number = Integer.parseInt(userNum);
            return number;
        }and 2. How can I keep my whole play() in a loop? So that the game starts over
    my play() right now:
    public void play()
            getRandom();
            while(random!=number)
                getGuess();
                checkGuess();
            numberGuesses = 0;
            playAgain();
        }sorry, first year student!
    thanks for any help. All of the code if needed:
    import javax.swing.JOptionPane;
    import java.util.Random;
    * High-Low (HiLo) game. User guesses numbers while trying to guess a random number. Number of guesses is recorded and the user is told
    * at the end of the game after winning.
    * @author ----------
    * @version 11/18/2010
    public class HiLo
        String randomNumber = "";
        String userNum = "";
        int random;
        int number;
        int numberGuesses;
         * Asks player if he wants to play, gets random number, gets user guess, checks the users guess, asks to repeat.
        public void play()
            getRandom();
            while(random!=number)
                getGuess();
                checkGuess();
            numberGuesses = 0;
            playAgain();
         * Gets the users guess.
        public int getGuess()
            userNum = JOptionPane.showInputDialog ("Guess a number between 0 and 100");
            number = Integer.parseInt(userNum);
            return number;
         * Gets a random number between 0 and 100
         * int named random
        public int getRandom()
            Random randomNumber = new Random();
            random = randomNumber.nextInt(101);
            return random;
         * Checks to see if the user's guess is an integer, between 0 and 100, and returns if
         * they're guess is too high or too low.
        public void checkGuess()
            numberGuesses = numberGuesses+1;
            if (number==random)
                JOptionPane.showMessageDialog(null, "You Win!" + " " + "Number of guesses:" + " " + numberGuesses);         
            else if (number<random)          
                JOptionPane.showMessageDialog(null, "Too low, guess again!");
            else if (number>random)      
                JOptionPane.showMessageDialog(null, "Too high, guess again!");
         * Asks the user if they want to play again.
        public void playAgain()
            JOptionPane.showMessageDialog(null, "play again?");         
    }-javaStudent

  • I had 10$ gift card that works only on US. I redeemed the gift card but back in the game i get buy stuff and it says "you cant buy in US store you must swich bla bla bla" i dont want ti swich because the 10 $ works only at the US store. Help please.

    I had 10$ gift card that works only on US. I redeemed the gift card but back in the game i get buy stuff and it says "you cant buy in US store you must swich bla bla bla" i dont want ti swich because the 10 $ works only at the US store. Help please.

    Hello SBentley22,
    I can only imagine how upset I would be to discover that over $1000 in gift card funds seemed to be missing. I certain that I would not do well with the additional complications that you've described either. I apologize for you and your boyfriend having to cope with this situation. Certainly this was never our goal.
    I was unable to locate the purchases or returns that you mention using the information you provided when you signed up for Best Buy Unboxed. I would very much like to look into this situation for you and do what I can to help, but I will need more information to begin. If you will please send me a private message that includes your full name, telephone number, and the Customer Service PIN from the receipt where the gift card was issued, I'll get started with my research.
    Please know that I'm extremely grateful that you took the time to bring your situation to our attention. I look forward to hearing from you.
    Sincerely,
    John|Social Media Specialist | Best Buy® Corporate
     Private Message

  • STILL "No valid licence for this book" message. Help please.

    I bought my first ebook in December from Waterstones for my Elonex ereader and this was ok. The next two books purchased from Waterstones came up with the message, "No valid lisence for this book." After trying to solve the problem of not being able to open/read them I ended up with, "Too many activations." I managed to get my activations re-set, yet am still unable to open/read the books because  I am getting the same message, "No valid lisence for this book." I have sent the case to Adobe, but as I waited and waited for the activations to be re-set I could be in for another long wait! Can anyone help please.

    I am having the same problem with my elonex 511tEB. Did you manage to get yours sorted out and can you please tell me how  to do it.
    I would be very grateful if you could help me as i am puzzled with it all.
    My email add is : [email protected]
    Regards
    Aileen Buckley

  • Switch method need help please ;-(

    Hello, I am having trouble with this switch method. I have yet ot construct the AirplaneList object "plane". For I have yet to be taught about it properly
    Can someone at least help me with the switch incident. I have learnt how to make a menu for the user to input the letters A-F in uppercase and lower case. However I am unsure on how to associate "case a" to the method
    //add Airplane
    public static void option1 (AirplaneList plane)
    ? I can get it to print out "case a" continueosly, but how to I associate it to the method. I am aware that the AirplaneList will be a class I have to define earlier, and that "plane" is an object I will need to intiate. If anyone will be willing to help me construct this part of the code I can award them Duke dollars.
    as far as I can tell the constructor method would start off like
    AirplaneList plane = new AirplaneList;
    ok? then what do I do?
    do I define its methods then?
    plane.add()
    Ok well this is the majority of the code I have already.
    import javax.swing.JOptionPane; //indicates that the compiler should load class JOptionPane for use in this application.
    public class AirplaneListT
         public static void main (String[] args)
    throws java.io.IOException
              char choice; //Words choice and size are the names of variables
         //     int size; //This declaration specifies that the variable are of data type char and int
         //     size = EasyIn.getInt(); // Converts size from int to something?
         //Char - a variable that may only hold a single lowercase letter, a single uppercase letter, a single digit or a special character
    //(such as x, $, 7 and *)
         // The code below creates a dialog box for the user to input a choice
         String inputcode;
         inputcode = JOptionPane.showInputDialog("A: add an airplane from the list\n" +
                                  "B: remove an airplane from the list\n" +
                                  "C: check if the list is empty\n" +
                                  "D: check if the list is full\n" +
                                  "E: display the list\n" +
                                  "F: quit\n" );
         JOptionPane.showMessageDialog(null, "You have chosen choice " + inputcode);
    //The null first argument indicates that the message dialog will appear in the center of the screen. The 2nd is the message to display
    do
         // get choice from user
         choice = inputcode.toUpperCase().charAt(0);
              System.out.println();
              //process menu options
              switch(choice)
                   case 'A':
                   case 'a':
                        JOptionPane.showMessageDialog(null, "Case " + inputcode);
                        break;     //done processing case
                   case 'B':
                   case 'b':
                        JOptionPane.showMessageDialog(null, "Case " + inputcode);
                        break;     //done processing case
                   case 'C':
                   case 'c':
                        JOptionPane.showMessageDialog(null, "Case " + inputcode);
                        break;     //done processing case
                   case 'D':
                   case 'd':
                        JOptionPane.showMessageDialog(null, "Case " + inputcode);
                        break;     //done processing case
                   case 'E':
                   case 'e':
                        JOptionPane.showMessageDialog(null, "Case " + inputcode);
                        break;     //done processing case
                   case 'F':
                   case 'f':
                        JOptionPane.showMessageDialog(null, "Case " + inputcode);
                        break;     //done processing case
                   default:
                        JOptionPane.showMessageDialog(null, "Invalid entry!");
                        break;     //done processing case
         }while (choice!= 'F' || //end AirplaneList tester
         choice!= 'f' );
    //add Airplane
         public static void option1 (AirplaneList plane)
              String flight;
              flight = JOptionPane.showInputDialog("Please enter airplane filght number" );
              //create an Airplane object to add to list
              Airplane flight = new Airplane();
              //add string to list if the list is not full
              //access the 'add(Airplane)' method from the AirplaneList class;
              //if the list is full, return a statement to the user indicating that no more plane can be added onto the list
         //remove airplane
         public static void option2 ()
              //get position of item
         string enterpos;
         enterpos = JOptionPane.showInputDialog("Please enter position to remove" );
              System.out.print(":")
              int plane = Easyln.getint();
              // delete item if it exists
              //access the 'remove(Airplane)' method from the AirplaneList class;
              //if the user enter an invalid number for the position, returen a statement
              //indicating that there is no such posititon.
         //check if empty
         public static void option3 (AirplaneList plane)
              if (plane.isEmpty())
                   JOptionPane.showInputDialog("list is empty" );
              else
                   JOptionPane.showInputDialog("list is not empty" );
         //check if full
         public static void option4 (AirplaneList plane)
              if (plane.isFull())
                   JOptionPane.showInputDialog("list is full" );
              else
                   JOptionPane.showInputDialog("list is not full" );
         //display list
         public static void option5 (AirplaneList plane)
              if (plane.isEmpty())     //no need to display if list is empty
                   JOptionPane.showInputDialog("list is empty" );
              else
                   JOptionPane.showInputDialog("Airplanes in list are" );
                   //loop through list
         System.exit(0); //Terminates the program

    case 'A':
    case 'a':
    JOptionPane.showMessageDialog(null, "Case " + " + inputcode);
    break;     //done processing case
    ok are u saying if i invoke a method i go something
    like this?
    case 'A':
    case 'a':
    JOptionPane.showMessageDialog(null, "Case " + " + inputcode);
    AirplaneList.option1(); //Tell Airplanelist to add                    
    break;     //done processing caseIn both cases, you're calling methods. In the latter case, you're calling two methods.
    What's the problem exactly? What part are you having trouble with?
    ... so that then when case a is activated it should go
    onto option1 method?That's one thing you can do, yes. I don't know if you should do it. It depends on what your program needs to do.
    //add Airplane
         public static void option1 (AirplaneList plane)
              String flight;
    flight = JOptionPane.showInputDialog("Please enter
    r airplane filght number" );
              //create an Airplane object to add to list
              Airplane flight = new Airplane();
              //add string to list if the list is not full
    //access the 'add(Airplane)' method from the
    e AirplaneList class;
    //if the list is full, return a statement to the
    e user indicating that no more plane can be added onto
    the list
         }OK, this looks odd. Is this what you're having trouble with?
    BTW, I'd strongly suggest making a stronger separation of application code from GUI code.

Maybe you are looking for

  • Open a form

    This is got to be so simple but I am new to java and I have been programming in VB6 for years. I am trying to open the JFrame which I assume is same as form in VB. I have NetBeans 4.0 beta and it created a Main.java and I added frmMain.java which has

  • Why can't I download Adobe Camera Raw 8.4?

    When the download is about 85% finished, I get the attached error message: "Update Failed. Update could not be applied." Here's the error code: Error Code: U44M1P7 This has happened three times in a row. I'm on a MacBook Pro running OS X 10.9.3 Any s

  • Problems with import CLOBs - illegal lob length marker

    Hi All !! I tried to import table with CLOB, I get the following message: illegal lob length marker 55086 bytesread = 00030955520 TABLE = IMP-00098: INTERNAL ERROR: impgst2 Any ideas? Thanks.

  • SAP Authentication error in Nakisa 3 SP1

    Hi, I have uploaded the serial key and performed the below steps as per the Admin guide for sucession planning Test the required data connections in the Data Center (configured SAp connection) Verify the security authentication settings (for login sc

  • Button background fill "Linear - to top" not showing after save.

    I've made the proper edits to make these buttons look very "cool" having the background filled to a gradient look which is called "Linear to top", but once I save this form and open the PDF the button color is solid rather then gradient or "linear to