Hi guys

I can't seem to get a new line in a

JOptionPane.showMessageDialog(null, " ");

statement. I try the /n command, but it still doesn't seem to work.

Is there any way I can get a paragraph in a dialog box like this?


That because the slash is the opposite direction not forward slash "/" but backward slash "\"

import javax.swing.JOptionPane;

public class NewLine
	public static void main(String[] args)
			(null, "peter_budo"+"\nCode tags enforcer"
				,"My Message", JOptionPane.WARNING_MESSAGE);

Thanks so very much, I keep on making these stupid errors.

Just on the side, is there any way to edit the title of the showMessageDialog? and possibly the icon?

Thanks again.

EDIT: Are the strings ,"My message", and JOptionPane.WARNING_MESSAGE
Exactly what I'm looking for? What are the keywords for different icons?
Sorry, I never actually compiled it, I just had a look.

Check the API doc for JOptionPane. The dialogs have several constructors you can choose from depending on how much you want to specify on it. The docs describe the constants you can supply for each of the parameters.

I hate to be beaten for fastest answer :twisted:

Yes "My message" is title that you can edit

Other possible messages types

Anyway here is tutorial on How to Make Dialogs from Java Sun website

commented: hehe... you have to settle for silver in the answer race :P +12

Ok, thanks very much.

And thanks for helping with my petty questions.

Thread solved.

As long you attempt to make the thing works and do not expect it to do it all for you there is always some willing person to help. It doesn't matter how trivial the question can be.
Any of us walked the same road, with differentiate only in distanced covered and directions taken on the cross roads...

Publilius Syrus
(~100 BC)


More likely
(2008 AD)

LOL nice,

I thought you were going to ask wtf I was talking about.