aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes MenuItem font setting Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "MenuItem font setting" Watch "MenuItem font setting" New topic
Author

MenuItem font setting

Sanjeev Charla
Ranch Hand

Joined: Apr 02, 2009
Posts: 90

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

Joined: Oct 24, 2010
Posts: 563
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.


Always learning Java, currently using Eclipse on Fedora.
Linux user#: 501795
Sanjeev Charla
Ranch Hand

Joined: Apr 02, 2009
Posts: 90

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

Joined: Oct 27, 2005
Posts: 19762
    
  20

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.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4658
    
    5

http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6285881
http://forums.dzone.com/java/3169-java-awt-trayicon-javax-swing-jpopupmenu.html

luck, db
There are no new questions, but there may be new answers.
Sanjeev Charla
Ranch Hand

Joined: Apr 02, 2009
Posts: 90

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.
 
jQuery in Action, 2nd edition
 
subject: MenuItem font setting