简体   繁体   English

Eclipse RCP中“关于”对话框中的字体

[英]Font in 'About' dialog in Eclipse RCP

I am currently using Ecplise RCP to develop a small application. 我目前正在使用Ecplise RCP来开发一个小应用程序。

My question is, how do I change the font in the About dialog box alone. 我的问题是,如何单独更改“关于”对话框中的字体。

Can somebody help me? 有人能帮助我吗?

If you have added the "About" menu item via a command/menu contribution or via the "ActionFactory.ABOUT.create(window);" 如果您通过命令/菜单贡献或通过“ActionFactory.ABOUT.create(window)”添加了“关于”菜单项; function then you can override the default "about" command handler by providing your own handler. 函数,然后您可以通过提供自己的处理程序覆盖默认的“约”命令处理程序。

Add this to your plugin.xml: 将其添加到plugin.xml:

<extension
     point="org.eclipse.ui.handlers">
  <handler
        class="my.AboutActionHandler"
        commandId="org.eclipse.ui.help.aboutAction">
  </handler>

then create the my.AboutActionHandler class: 然后创建my.AboutActionHandler类:

package my;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.ui.handlers.HandlerUtil;

public class AboutActionHandler extends AbstractHandler {
  @Override
  public Object execute(ExecutionEvent event) throws ExecutionException {
    new MyAboutDialog(HandlerUtil.getActiveShellChecked(event)).open();
    return null;
  }
}

At this point of time you really want to create the MyAboutDialog class as a subclass of the built-in AboutDialog class and simply override the configureText method but unfortunately the AboutDialog class is "internal" so you cannot extend it --- doh! 在这个时候你真的想要创建MyAboutDialog类作为内置的AboutDialog类的子类,并简单地覆盖configureText方法但不幸的是AboutDialog类是“内部的”所以你不能扩展它--- doh!

My recommendation is to simply open the AboutDialog class in Eclipse (shift-ctl-t AboutDialog) and copy paste the source into your own MyAboutDialog class; 我的建议是在Eclipse中打开AboutDialog类(shift-ctl -t AboutDialog)并将源代码粘贴到你自己的MyAboutDialog类中; then just edit the configureText method to set the font you want. 然后只需编辑configureText方法来设置所需的字体。 Not the most elegant option I admit but I can't see any other way. 不是我承认的最优雅的选择,但我看不到任何其他方式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM