Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » how to get current font used for treeviewer?(Using the system font)
how to get current font used for treeviewer? [message #491817] Fri, 16 October 2009 00:08 Go to next message
Natasha D'Silva is currently offline Natasha D'SilvaFriend
Messages: 25
Registered: July 2009
Junior Member
Hi,
I have a TreeViewer, and based on certain conditions, I would like its label provider to return a bold font for some elements.

What is the proper way to do this?
How do I know what the current font is for the view?
If the user changes the default settings and makes their font larger or smaller, I would prefer if my code was oblivious to that, and the code below is not.
My label provier implements ITableFontProvider, and right now, this is what I have:

	public Font getFont(Object element, int columnIndex) {

			if(condition) {
			FontData fontData = Display.getCurrent().getSystemFont()
						.getFontData()[0];
				String name = fontData.getName();
				return JFaceResources.getFontRegistry().getBold(name);
			}
		}
		return null;
	}





Right now, the above code appears to work, but if I change my wnidows color scheme to use larger fonts, the font returned by Display.getCurrent().getSystemFont()
.getFontData()[0]; is different and smaller.
If I do not supply a bolded font for an element, its font is in sync with the system font, so how do I get the current font, and make it bold?
Thanks.
Re: how to get current font used for treeviewer? [message #491820 is a reply to message #491817] Fri, 16 October 2009 00:32 Go to previous message
Remy Suen is currently offline Remy SuenFriend
Messages: 462
Registered: July 2009
Senior Member
On Thu, 15 Oct 2009 20:08:34 -0400, Natasha D'Silva wrote:
> What is the proper way to do this?
> How do I know what the current font is for the view?

Can't you just invoke getFont() on your TreeViewer's Tree?

Remy
Previous Topic:blockOnOpen = false for Wizards
Next Topic:Manage focus of CellEditor in TableViewer
Goto Forum:
  


Current Time: Fri Nov 28 19:50:02 GMT 2014

Powered by FUDForum. Page generated in 0.33247 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software