简体   繁体   English

更改jface对话框的背景颜色

[英]Change background color of jface Dialog

I would like to change the default grey background of a jface.dialogs.Dialog derived Class. 我想更改jface.dialogs.Dialog派生类的默认灰色背景。 On here I read that this has to be done manually for each control. 这里,我读到必须对每个控件手动完成此操作。

So far, I was able to change all colors, except the color around the "OK" and "Cancel" button area. 到目前为止,我可以更改所有颜色,除了“确定”和“取消”按钮区域周围的颜色。 Does anyone know how to do this? 有谁知道如何做到这一点?

在此处输入图片说明

Override the createButtonBar method in your dialog: 覆盖对话框中的createButtonBar方法:

@Override
protected Control createButtonBar(final Composite parent)
{
  final Composite barComp = (Composite)super.createButtonBar(parent);

  barComp.setBackground(your color);

  return barComp;
}

If you are using Eclipse 4.4 you can set the color to be something specified in the application CSS by using 如果使用的是Eclipse 4.4,则可以通过使用以下命令将颜色设置为应用程序CSS中指定的颜色

WidgetElement.setCSSClass(barComp, "css-class-name");

instead of the setBackground 而不是setBackground

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

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