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?
You could use '\n' like so:
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);