File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT / JFace and the fly likes Universal Font Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT / JFace
Reply Bookmark "Universal Font" Watch "Universal Font" New topic
Author

Universal Font

Gregg Bolinger
Sheriff

Joined: Jul 11, 2001
Posts: 15040

I know how to change the font for an individual component, but I would like to have one font used for every component in my Swing Application. Can someone tell me how to do this.
Thanks

------------------
Happy Coding,
Gregg Bolinger


My Blog | DZone Articles
Gregg Bolinger
Sheriff

Joined: Jul 11, 2001
Posts: 15040

Ok, I think I have found out a way to do this. But you have to do it for each component. For example, to make a universal font for a JButton I create a new class called buttonFontSetter and extend JButton then I set my font in that class and call that method instead of JButton to create my buttons.
I would have to do the same for my TextFields, Labels, etc. But it works. Just now I have to go and change all my JButton calls. EEKK! Oh well. Such is the life of a programmer.
Ta Ta

------------------
Happy Coding,
Gregg Bolinger
Renee Zhang
Ranch Hand

Joined: Sep 10, 2001
Posts: 72
If I need one font for several components, I'd like to create a font object. For example:
Font customFont = new Font("Dialog", 0, 14);
//Then set component's font to customeFont
buttonOne.setFont(customeFont);
labelOne.setFont(customeFont);
.....
I don't know if I can override something to change the default font. Does anyone know?
Gregg Bolinger
Sheriff

Joined: Jul 11, 2001
Posts: 15040

I would just like to know what the default font is in Windows so that I can set that as the default so that when I take my App over to Linux, it looks the same. As it is now, the font is spaced and seized different and appears larger.
------------------
Happy Coding,
Gregg Bolinger
Paul Stevens
Ranch Hand

Joined: May 17, 2001
Posts: 2823
I don't think that there is a quarantee that it will look alike. Even with the same font and size.
Gregg Bolinger
Sheriff

Joined: Jul 11, 2001
Posts: 15040

That's what I was fearing. Thank you for the response.

------------------
Happy Coding,
Gregg Bolinger
 
 
subject: Universal Font
 
Threads others viewed
how to get system font?
Font
customize tomahawk schedule component
Uniform Font for class of swing components
Font
IntelliJ Java IDE