• Post Reply Bookmark Topic Watch Topic
  • New Topic

Setting custom font JOptionPane  RSS feed

 
Zkr Ryz
Ranch Hand
Posts: 187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does anyone knows how can I set a custom Font to a JOptionPane ??
The method showMessageDialog shows the dialog, but I dont know how ca I customize the font.
 
kyle amburn
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The message is of type Object. If you create a JLabel and specify the font for the JLabel and then pass the JLabel as the message object, this should achieve the desired effect.
Kyle
 
Zkr Ryz
Ranch Hand
Posts: 187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Kyle, it work!!, , but now, I have the message with a font and the buttons in the old thick ugly font ???
Do you know how to change the buttons font ?
 
kyle amburn
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Create a JButton for each button and change the font. Use the showOptionDialog(...) method of JOptionPane. Wrap each of your buttons in an Object[] and pass as the option paramater to this method.
Kyle
 
Zkr Ryz
Ranch Hand
Posts: 187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks!!!
But, I've loose the default behavior though.
(
I think I would have to make a custom JDialog for this..
Thanks anyway
 
Daniel Akesson
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cool, just the problem I had. However, if I got \n (newlines) in the text, JLabel's aint enough, since then all the text is on one line. Suggestions to solve this?

Edit: Seems like JTextArea is the closest to the answer, although the bg color is white on that by default.. bah!

[ July 05, 2004: Message edited by: Daniel Akesson ]
[ July 05, 2004: Message edited by: Daniel Akesson ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!