简体   繁体   English

如何在GWT中更改DecoratorPanel的颜色?

[英]How can I change the color of a DecoratorPanel in GWT?

I see that it uses png images for the rendering, so I am assuming that means I need to provide my own version of these images, with colors changed appropriately. 我看到它使用png图像进行渲染,所以我假设这意味着我需要提供自己的这些图像版本,并适当更改颜色。 Where do I put these images, and how do I apply them in the CSS? 我将这些图像放在哪里,以及如何在CSS中应用它们?

OK, so here's the solution. 好的,这就是解决方案。

  • Go to the GWT Theme Generator 转到GWT主题生成器
  • choose the color you want 选择你想要的颜色
  • choose a name for your style 为您的风格选择一个名字
  • click generate 点击生成
  • take the jar file it produces, and add it to your classpath 提取生成的jar文件,并将其添加到您的类路径中
  • add a reference to the new style in your app.gwt.xml file 在您的app.gwt.xml文件中添加对新样式的引用

If you're unhappy with using the Theme Generator, or afraid it might disappear one day, just do it once and thereafter hack the contents of the jar file it produces. 如果您对使用主题生成器不满意,或者担心它可能有一天消失,则只需执行一次,然后破解它生成的jar文件的内容。

You can use he following code to apply your own CSS style for Decorator panel. 您可以使用以下代码为Decorator面板应用自己的CSS样式。

 DecoratorPanel panel=new DecoratorPanel();
 panel.setStyleName("decorator-panel");

In your css file you can apply styles to decorator-panel.Using this we can change colour.For image you create one image directory under public directory(the directory which is having your css file) and put your image there.Then in css you can get image. 在您的css文件中,您可以将样式应用于装饰面板,从而改变颜色。对于图像,您可以在公共目录(包含css文件的目录)下创建一个图像目录,然后将图像放在该目录中。可以得到图像。

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

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