我正在我的类(class)中扩展 TitleAreaDialog。
标题区域中标题的默认字体看起来不太好。
可以更改标题的字体吗?
我不需要更改代码中其他位置的字体,只需更改标题文本。
我尝试过使用 FontRegistry 以及 StyledText。
但我不知道如何将新字体分配给 setTitle()。
FontRegistry fontRegistry = JFaceResources.getFontRegistry();
FontData mainFont = new FontData("Garamond", 18, SWT.NORMAL);
fontRegistry.put("mainFont", new FontData[]{mainFont});
?.setText("Title Text");
?.setFont(fontRegistry.get("mainFont"));
setTitle(?);
最佳答案
我真的认为这是不可能的。 title
String
您通过 setTitle(String)
设置显示在 private
领域titleLabel
。您无法访问此 Label
当你子类化TitleAreaDialog
时。因此,您不能应用 Font
到它。
所以我能想到的唯一可能性就是创建你自己的 MyTitleAreaDialog extends TrayDialog
基于原代码TitleAreaDialog
并设置您Font
那里。您可以在 SWT.jar 中或在线找到源代码。
关于java - TitleAreaDialog - 更改 setTitle 的字体 ("abc"),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12981748/