Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java: Multiple lines of text using JOptionPane.showInputDialog(null, "Text");

I need a text pop up like the one you get with JOptionPane.showInputDialog(null, "Text"); Just with multiple lines, like...

I'm new to java.
I have no background in programming.
I could use some help

How would I do this?

like image 449
jjd712 Avatar asked Aug 25 '12 00:08

jjd712


People also ask

What is JOptionPane showInputDialog in Java?

Common Methods of JOptionPane class It is used to create a dialog with the options Yes, No and Cancel; with the title, Select an Option. static String showInputDialog(Component parentComponent, Object message) It is used to show a question-message dialog requesting input from the user parented to parentComponent.

What is null in JOptionPane?

Passing null to it just indicates that there's not an associated "parent" dialog - ie, the dialog being displayed does not belong to another dialog.

How do you skip a line in JOptionPane?

You have to use \n to break the string in different lines.


1 Answers

You could use '\n' like so:

JOptionPane.showMessageDialog(null, "Hello\nworld");
like image 167
David Kroukamp Avatar answered Oct 04 '22 15:10

David Kroukamp