是否可以在 JOptionPane 中将文本右对齐?(我不想用JDialog)因为我想用阿拉伯语写一些句子
12227 次
4 回答
6
创建一个 JPanel,在 JPanel 中对齐文本,然后将 JPanel 添加为 JOptionPane 的 Object 参数。或者使用 JDialog(为什么不希望使用其中之一?)。
于 2011-06-23T13:38:06.210 回答
6
String message = "<html><body><div width='200px' align='right'>This is some text!</div></body></html>";
JLabel messageLabel = new JLabel(message);
JOptionPane.showConfirmDialog(null, messageLabel);
于 2011-06-23T13:43:02.803 回答
3
于 2011-06-23T13:38:26.353 回答
3
正如... Hovercraft Full Of Eels所述,您完全可以将 JComponent 用作JOptionPane#showMessageDialog
. 因此,JPanel
使用 a创建 a GridBagLayout
,将 aJLabel
与您的文本一起放入其中,使用右集 ofGridBagConstraints
确保文本右对齐,瞧!具有右对齐文本的 JOptionPane。
于 2011-06-23T13:44:24.177 回答