我需要一个文本弹出窗口,就像使用JOptionPane.showInputDialog(null, "Text");
时弹出的那种。只不过需要多行文本,就像...
I'm new to java.
I have no background in programming.
I could use some help
我该如何做到这一点?
我需要一个文本弹出窗口,就像使用JOptionPane.showInputDialog(null, "Text");
时弹出的那种。只不过需要多行文本,就像...
I'm new to java.
I have no background in programming.
I could use some help
我该如何做到这一点?
JOptionPane.showMessageDialog(null, "Hello\nworld");
可能有一打其他方法可以做到这一点,但我能想到的最简单的方法是
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);
<html>我是Java新手。<br>
虽然这并不与此问题相关(在该问题中,提问者似乎知道他们想要插入换行符的位置),但至少J2SE支持将CSS width
属性添加到body
元素中。 这可以帮助我们避免在多行文本中找出放置换行符的位置。 :) - Andrew Thompson
JOptionPaneTest
。 - trashgod