Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

MenuItem font setting

 
Sanjeev Charla
Ranch Hand
Posts: 90
Firefox Browser Ubuntu
  • Mark post as helpful
  • send pies
  • 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.
 
Greg Brannon
Bartender
Posts: 563
  • Mark post as helpful
  • send pies
  • 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
  • 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,
 
Rob Spoor
Sheriff
Pie
Posts: 20667
65
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • 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.
 
Darryl Burke
Bartender
Posts: 5148
11
Java Netbeans IDE Opera
 
Sanjeev Charla
Ranch Hand
Posts: 90
Firefox Browser Ubuntu
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic