Reputation: 766
I have a swing application with this code, which attempts to resize the font of a component:
Font f = new Font(Font.SERIF,Font.PLAIN,16);
component.setFont(f);
The program loads with 14 point font, and I include a component which lets the user resize the component to 16 point font as above. When I run this on the computer I compiled it on (Debian), it works as intended, but I tested it on a Mac and a Windows computer and the font resizing feature doesn't work at all. However, on all platforms the font is serif. Any ideas why this is happening?
Upvotes: 1
Views: 334
Reputation: 205785
The component's default UI delegate on your platform may be pre-empting your setting. In the alternative, consider one of the following:
Use deriveFont()
on the existing font, illustrated here.
component.getFont().deriveFont(16f)
Use an available sizeVariant
, illustrated here.
Upvotes: 1