• 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

MenuItem font setting

 
Ranch Hand
Posts: 90
Firefox Browser Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Setting Font to awt MenuItem will not effect its Font display, How ever, The font size , font style properties are updated.
I have used this property to set MenuItem font :

The above statement effects the swing JMenuItems, but awt MenuItems are not effected at all.
later i set the font property of each MenuItem, Then the font size, font style are effected. but font is not displayed.
I am able to set the font size, font style of awt MenuItems, but not displaying font. If i change the font, the same old default font is displaying with new style and size.
How to solve this issue ?

Thank you.
 
Bartender
Posts: 563
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
From the API, AWT's MenuComponent's setFont() method is inherited from Component. It is noted that setFont() may not work on all platforms, leaving the font unchanged. Swing's JMenuComponent's setFont() is inherited from JComponent, overriding Component's setFont(). The same limitation is not mentioned.

So the code is different. You could download the source code to determine the differences and better understand why the two setFont() methods provide different results.

Swing is preferred over AWT for many reasons, and use of AWT is generally discouraged where Swing alternatives exist.
 
Sanjeev Charla
Ranch Hand
Posts: 90
Firefox Browser Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the replay,
Yes, i always want to use Swing instead of AWT. But presently in application i want system tray access. TrayIcon class has method only. That is the problem here. Any way is there any way to set uni code fonts to the components of PopupMenu ??

thank you,
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
UIManager does not work for AWT, only for Swing. As for the results of setFont not being used, that's possibly because of how the tray icon is implemented. I fear that if that method isn't working, nothing will be working apart from perhaps writing your own tray icon implementation.
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6285881
http://forums.dzone.com/java/3169-java-awt-trayicon-javax-swing-jpopupmenu.html
 
Sanjeev Charla
Ranch Hand
Posts: 90
Firefox Browser Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the responses,
The given links contain, the exact problem i am facing. I have expected the swing version of tray icon in jdk7. After the release of JDK7 i have searched javadocs interestingly for that component.
Here my application perfectly runs in ubuntu linux with all unicode characters displaying. But of course the look and feel is motif, so it is not so aesthetically pleasing when compared to other look and feels. Anyway i came to conclude that, displaying PopupMenu will be dependent on implementation of JVM and Underlying platform, Otherwise i have to use other third party implementations.
 
Look! It's Leonardo da Vinci! And he brought a tiny ad!
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic