我使用的是 Vaadin 6.8.13,我创建了自己的主题,只是为了设置单个按钮的样式。我正在使用 Eclipse Luna 和 Vaadin 插件,我还在 Liferay 上将 vaadin 应用程序部署为一个 portlet。但是我的主题不起作用...
我已经完成了本书的所有工作,事实上,我使用 eclipse 中的 vaadin 主题向导为我完成了所有工作。例如创建
WebContent/VAADIN/themes/mytheme/styles.css
并在应用程序类中添加 this.setTheme("mytheme");
。但无济于事,我的 styles.css 文件如下所示:
@import url(../liferay/styles.css);
.v-button-wrap {
background: #b20000 !important; /* Old browsers */
background: -moz-linear-gradient(top, #b20000 0%, #e50000 50%, #b20000 100%) !important; /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#b20000), color-stop(50%,#e50000), color-stop(100%,#b20000)) !important; /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #b20000 0%,#e50000 50%,#b20000 100%) !important; /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #b20000 0%,#e50000 50%,#b20000 100%) !important; /* Opera 11.10+ */
background: -ms-linear-gradient(top, #b20000 0%,#e50000 50%,#b20000 100%) !important; /* IE10+ */
background: linear-gradient(to bottom, #b20000 0%,#e50000 50%,#b20000 100%) !important; /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#b20000', endColorstr='#b20000',GradientType=0 ) !important; /* IE6-9 */
color: #ffffff;
text-shadow: none;
}
.v-button-wrap:hover {
border: 1px solid #990000 !important;
}
我的 Application 类如下所示:
import com.vaadin.Application;
import com.vaadin.ui.*;
/**
* Main application class.
*/
@SuppressWarnings("serial")
public class CheckroutesportletApplication extends Application {
@Override
public void init() {
// Initializes the container and sets the main_screen
Window container = new Window("Check Routes");
container.addComponent(new MainScreen());
setMainWindow(container);
this.setTheme("mytheme");
}
}
有人知道为什么会发生这种情况吗?人们可能会犯的常见错误?
最佳答案
我认为您的问题是,在 vaadin 布置任何内容之前,您需要将 setTheme 作为 init 中的第一项。
关于java - 我的自定义 Vaadin 6 主题不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25201319/