でのように、私は、VerticalLayoutパネルの境界のためにいくつかの色を宣言:GWT UiBinderサンプルメッセージCSSスタイリング
<ui:style>
.onMouseOverBorderColor {border-color: red; border-style: outset}
.onMouseOutBorderColor {border-color: black; border-style: outset}
</ui:style>
それから私は、マウスの位置に応じて、パネルの枠線の色、そして私を変更したいです私のウィジェットのコンストラクタに以下を追加してください:
clickable.addMouseOverHandler(new MouseOverHandler() {
@Override
public void onMouseOver(MouseOverEvent event) {
GWT.log("mouse over");
border.setStyleName("onMouseOverBorderColor");
}
});
clickable.addMouseOutHandler(new MouseOutHandler() {
@Override
public void onMouseOut(MouseOutEvent event) {
GWT.log("mouse out");
border.setStyleName("onMouseOutBorderColor");
}
});
しかし、何も起こりません!私は間違っていますか?
提案後のコード(動作しない):
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui">
<ui:style>
.fontStyleTitle {font-weight: bold }
.border {border-color: black; border-style: outset}
.border:hover {border-color: red; border-style: outset}
</ui:style>
<g:FocusPanel ui:field="clickable">
<g:VerticalPanel ui:field="border" borderWidth="1" styleName="style.border">
<g:Image ui:field="myImage"/>
<g:Label ui:field="myTitle" horizontalAlignment="ALIGN_CENTER" styleName="{style.fontStyleTitle}"/>
</g:VerticalPanel>
</g:FocusPanel>
</ui:UiBinder>
とJavaクラス:
public UiWidget(String path, String theTitle) {
initWidget(uiBinder.createAndBindUi(this));
GWT.log(URL_PREFIX+path);
myImage.setUrl(URL_PREFIX+path);
myTitle.setText(theTitle);
myImage.setSize(IMG_WIDTH, IMG_HEIGHT);
/*
clickable.addMouseOverHandler(new MouseOverHandler() {
@Override
public void onMouseOver(MouseOverEvent event) {
GWT.log("mouse over");
}
});
clickable.addMouseOutHandler(new MouseOutHandler() {
@Override
public void onMouseOut(MouseOutEvent event) {
GWT.log("mouse out");
}
*/
}
おかげで私のコードを変更しました - 私の元の投稿に示されているように - しかし、私は希望の効果が表示されません。コードは正しいですか? '' styleNameに= "{} style.border": –
あなたは括弧を忘れてしまいました –