1
我有一個應用程序將有很多窗口,所以我有必要創建一個包含FontRegistry
實例的單例,並讓該單例管理FontRegistry
的內容。我的代碼看起來是這樣的:JFace FontRegistry字體處理
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;
}
}
我想知道是,我說得對不對,立即處置mainFont
?