tags:

views:

37

answers:

0

I have an application which will have many windows, so it makes sense to me to create a singleton that holds a FontRegistry instance and have that singleton manage the FontRegistry's contents. My code looks something like this:

import org.eclipse.jface.resource.FontRegistry;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.widgets.Display;

public final class FontRegistryManager {
    public static final FontRegistryManager INSTANCE = new FontRegistryManager();

    FontRegistry fr;

    private FontRegistryManager() {
        fr = new FontRegistry();

        Display currentDisplay = Display.getCurrent();
        Font mainFont = new Font(currentDisplay, "Tahoma", 8, 0);           
        fr.put(FontRegistryConstants.MAIN_FONT, mainFont.getFontData());
        mainFont.dispose();
    }

    public FontRegistry getFR() {
        return fr;
    }
}

What I'm wondering is, am I right to immediately dispose of mainFont?