Java/GWT/ScrollListener
Use ScrollListener
package com.jexp.gwt.client;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.CheckBox;
import com.google.gwt.user.client.ui.ruposite;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.ScrollListener;
import com.google.gwt.user.client.ui.ScrollPanel;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;
import com.google.gwt.user.client.ui.RootPanel;
public class GWTClient implements EntryPoint{
public void onModuleLoad() {
LicensePanel e = new LicensePanel("License: scroll to enable the check box");
RootPanel.get().add(e);
}
}
class LicensePanel extends Composite {
private VerticalPanel vPanel = new VerticalPanel();
final Label text;
private ScrollPanel sPanel = new ScrollPanel();
private CheckBox accept = new CheckBox("Accept Terms");
public LicensePanel(final String licenseText) {
text = new Label(licenseText);
sPanel.setAlwaysShowScrollBars(true);
sPanel.setHeight("100px");
sPanel.setWidth("200px");
sPanel.add(text);
accept.setChecked(false);
accept.setEnabled(false);
vPanel.add(sPanel);
vPanel.add(accept);
initWidget(vPanel);
sPanel.addScrollListener(new ScrollListener() {
public void onScroll(Widget sender, int x, int y) {
Widget textItem = sPanel.getWidget();
if (sPanel.getOffsetHeight() + y >= textItem.getOffsetHeight())
{
accept.setEnabled(true);
}
}
});
//setStyleName("licensePanel");
}
public boolean isAccepted() {
return accept.isChecked();
}
}