首页 > 解决方案 > 为什么 joptionpane 不支持 \t?

问题描述

所以我的问题很简单,为什么 JOptionPane 不允许您使用/不支持“\t”?但是否允许您使用/支持“\n”?

我知道如何通过使用 HTML 或 jTextArea 来解决这个问题......但是这些方法添加了不必要的代码,那么为什么 oracle 不在 JOptionPane 中添加对“\t”的支持,以帮助保持代码简单?

例如 ...

JOptionPane.showMessageDialog(null,"This is the first line" + "\n" + "This is the second line" + "\t" + "< there should be a tab here");

产生这个...

在此处输入图像描述

这不是应该发生的事情,因为我正确放置了标签。那么为什么会发生呢?

标签: javatabsjoptionpane

解决方案


推荐阅读