I'm trying to find the color of an element with GWT, but am getting nothing (empty string) returned. What's my problem? The following code illustrates the problem:
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.Scheduler;
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.user.client.ui.Anchor;
import com.google.gwt.user.client.ui.RootLayoutPanel;
public class Test implements EntryPoint {
Anchor a = new Anchor("Anchor");
@Override
public void onModuleLoad() {
RootLayoutPanel.get().add(a);
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@Override
public void execute() {
log(a.getElement().getStyle().getColor());
log(a.getElement().getStyle().getVisibility());
log(a.getElement().getStyle().getPosition());
}
});
}
static native void log(String message) /*-{
console.log(message);
}-*/;
}
The console displays color and visibility as empty strings, whilst Position is shown as "absolute" (showing that the problem isn't with the logging). Result is the same in both Chrome and Firefox.