Reputation: 151
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?
Upvotes: 15
Views: 49541
Reputation: 347204
There's probably a dozen other ways to do this, but the simplest I can think of is
JOptionPane.showMessageDialog(null, "<html>I'm new to java.<br>I have no background in programming.<br>I could use some help Thanks!</html>");
Another approach to demonstrate the power of the JOptionPane
JTextArea msg = new JTextArea("This is a really silly example of what can be achieved with a JOptionPane, but this is going to excese for what you have asked for");
msg.setLineWrap(true);
msg.setWrapStyleWord(true);
JScrollPane scrollPane = new JScrollPane(msg);
JOptionPane.showMessageDialog(null, scrollPane);
Upvotes: 16
Reputation: 36423
You could use '\n' like so:
JOptionPane.showMessageDialog(null, "Hello\nworld");
Upvotes: 18