Align text to the right in JOptionPane

后端 未结 4 767
有刺的猬
有刺的猬 2021-01-24 00:43

Is it possible to align the text to the right in JOptionPane? (I don\'t want to use JDialog) because I want to write some sentences in Arabic

4条回答
  •  抹茶落季
    2021-01-24 01:07

    As stated by ... Hovercraft Full Of Eels, you perfectly can use a JComponent as message in a JOptionPane#showMessageDialog. As a consequence, create a JPanel using a GridBagLayout, put a JLabel in it with your text, use the righ set of GridBagConstraints to ensure the text is right-align, and voila ! A JOptionPane with a right-aligned text.

提交回复
热议问题