hi there im just new with java i just want to ask can 1 dialog box contain multiple lines i min like this one

JOptionPane.showMessageDialog (null,"\n "+EN ) ;

somehow i want to add just like

JOptionPane.showMessageDialog (null,"\n "+EN , "\n another messages here then" +DR , "\n and another messages again here then" +rd)) ;

those EN DR rd have their values to be calculated..
someone pls help..

Recommended Answers

All 20 Replies

"<html>  Some notice: <br>"
       + " - some text <br>"
       + " - some text <br>"
       + " - some text  </html>  "

What you asked or said works 100% right....

JOptionPane.showMessageDialog(null,"Yahoo\nHotmail\nGmail");

:) , Also urs one is correct.

Member Avatar for hfx642

You can also create a JPanel with GUI components and
display YOUR panel in the dialog.

JOptionPane.showMessageDialog(null,"Yahoo\nHotmail\nGmail");

:) , Also urs one is correct.

Hi there im quite confused.. i relly didnt get how to do that,, i only wanted to display several info in 1 dialog box.. im very new in java programming i only know how to display a simple dialog box..

Hi there im quite confused.. i relly didnt get how to do that,, i only wanted to display several info in 1 dialog box.. im very new in java programming i only know how to display a simple dialog box..

am by the way im using jcreator..

Did you try placing \n in the String where you want the new line to start?

"<html>  Some notice: <br>"
       + " - some text <br>"
       + " - some text <br>"
       + " - some text  </html>  "

hello there am is this code used for dialog boxes in java i honestly dont know wer to put that code?

Did you try placing \n in the String where you want the new line to start?

hi there,, am yes i already done that one..

EN=100;
DR=20;

JOptionPane.showMessageDialog (null,"\nMY SALARY IS "+EN ) ;
so the output is

MY SALARY IS 100

somehow i want to do this
JOptionPane.showMessageDialog (null,"\nMY SALARY IS "+EN , "\n MY DEDUCTION is" +DR )

so my output in a single dialog box is

MY SALARY IS 100
MY DEDUCTION is 20

whats wrong with my code pls help..
im using jcreator..

Did you try placing \n in the String where you want the new line to start?

theres no problem bout the \n the problem is with those +EN when it shall display its value.. i just cant combine them..

i just cant combine them..

When you get errors, please copy and paste the full text of the message here.

Use the + operator to concatenate Strings:
"String1" + " stuff" + " more " ==> "String1 stuff more "
The compiler will convert some primitives to Strings for you:
"String " + 1 + " more " will give "String 1 more "

JOptionPane.showMessageDialog (null,"\nMY SALARY IS "+EN + "\n MY DEDUCTION is" +DR );
commented: Don't spoonfeed, let the OP work it out. -3

@NormR1 I just gave the example to your explanation..

When you get errors, please copy and paste the full text of the message here.

Use the + operator to concatenate Strings:
"String1" + " stuff" + " more " ==> "String1 stuff more "
The compiler will convert some primitives to Strings for you:
"String " + 1 + " more " will give "String 1 more "

im sorry for late reply got problem with my connection but thanks a lot it works i have done it already while offline... Thanks a lot for helping,, this is a project for my java class to be submitted tomorrow,, i just had idea wat will be the output but dont have much knowledge about the code tnx for the help..

When you get errors, please copy and paste the full text of the message here.

Use the + operator to concatenate Strings:
"String1" + " stuff" + " more " ==> "String1 stuff more "
The compiler will convert some primitives to Strings for you:
"String " + 1 + " more " will give "String 1 more "

@NormR1 i realy get this on the minute you post it its just got bit problem on my connection i see that im wrong putting , instead i shud used + operator to display my stuff before having , to display the name of my msg box..

can i ask another question here or i shud post it on another thread w/c is i dont know how..

i ask another question here or i shud post it on another thread

Post the new question on another thread

@NormR1 i realy get this on the minute you post it its just got bit problem on my connection i see that im wrong putting , instead i shud used + operator to display my stuff before having , to display the name of my msg box..

can i ask another question here or i shud post it on another thread w/c is i dont know how..

i think im wrong with that, did i?

i think im wrong with that, did i?

Sorry, I don't understand what you are asking.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.