• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Setting custom font JOptionPane

 
Ranch Hand
Posts: 187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic