This week's book giveaway is in the HTML/CSS/JavaScript forum.
We're giving away four copies of Practical SVG and have Chris Coyier on-line!
See this thread for details.
Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Align Text in JOptionPane

 
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.
 
I love a good mentalist. And so does this tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!