Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

quick java help

Name: Anonymous 2011-03-25 6:16

having issues with this bit of java code:

  JOptionPane.showMessageDialog(null, "First line.",acctStr  +
                                                          "\n Second line.",nameStr +   
                                                          "\\n Your total for regular service is $%.2f  %n",regtotal );
             

showMessageDialog is red saying that The method showMessageDialog(Component, Object, String, int, Icon) in the type JOptionPane is not applicable for the arguments (null, String, String, String, double)
 i need to have a j option multi line output, but its not just text, some are also variables, what code am i missing?

Name: Anonymous 2011-03-25 6:46

I don't even remember the last time I dabbled in the JOptionPane.

First off, it doesn't accept double.  You look silly for even thinking puppy dog eyes could solve that problem.  Format the String outside of the dialog box - String.format() - and then pass it in; if you need an updating value, keep reformatting the String to the same reference and pray.  Here's your param explanation (from the javadoc; I shouldn't have to paste this!):
Component parentComponent - determines the Frame in which the dialog is displayed; if null, or if the parentComponent has no Frame, a default Frame is used
Object message - the Object to display
String title - the title string for the dialog
int optionType - an int designating the options available on the dialog: YES_NO_OPTION, or YES_NO_CANCEL_OPTION


Be mindful of the possibility of a HeadlessException.  And whatever you do, don't post here ever again.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List