java:使用joptionpane.showinputdialog的多行文本(null,“text”);

pxy2qtax  于 2021-07-09  发布在  Java
关注(0)|答案(2)|浏览(386)

我需要一个文本弹出像一个你得到的 JOptionPane.showInputDialog(null, "Text"); 只是多行,比如。。。

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

我该怎么做?

luaexgnf

luaexgnf1#

可能还有很多其他方法可以做到这一点,但我能想到的最简单的方法是

JOptionPane.showMessageDialog(null, "<html>I'm new to java.<br>I have no background in programming.<br>I could use some help Thanks!</html>");

另一种证明 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);

gcuhipw9

gcuhipw92#

您可以这样使用“\n”:

JOptionPane.showMessageDialog(null, "Hello\nworld");

相关问题