Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Align Text in JOptionPane  RSS feed

 
athrun itachi
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
i like to align my text in a particular format in a message dialog
as shown below


is there any way to do this ?
Thanks

[added code tags to preserve the formatting - Ilja]
[ April 24, 2005: Message edited by: Ilja Preuss ]
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to Swing...
 
James Carman
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try using a JLabel as your "message" of the JOptionPane and then use HTML text on the label.
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by James Carman:
Try using a JLabel as your "message" of the JOptionPane and then use HTML text on the label.


Or a JPanel with a GridLayout?
 
James Carman
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For purely textual layout, it might be overkill to use a JPanel with GridBagLayout (although it certainly will work). I wouldn't think that you would want to instantiate all of those JLabels or try to figure out how to get them all to line up like you want them using GridBagLayout. Most folks know how to do simple tables in HTML and that should suffice.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!