List of usage examples for com.google.gwt.user.client.ui ScrollPanel setHorizontalScrollPosition
@Override public void setHorizontalScrollPosition(int position)
From source file:asquare.gwt.tk.uitest.isvisible.client.Demo.java
License:Apache License
public void onModuleLoad() { RootPanel outer = RootPanel.get();/*w ww . j av a2s . co m*/ TextBox rowInput = new TextBox(); TextBox colInput = new TextBox(); Grid input = new Grid(2, 2); input.setText(0, 0, "Row: "); input.setWidget(0, 1, rowInput); input.setText(1, 0, "Col: "); input.setWidget(1, 1, colInput); outer.add(input); final int ROWS = 20; final int COLS = 20; Grid grid = new Grid(ROWS, COLS); grid.setCellPadding(0); grid.setCellSpacing(0); for (int row = 0; row < ROWS; row++) { for (int col = 0; col < COLS; col++) { grid.setWidget(row, col, new Label("(" + row + "," + col + ")")); } } ScrollPanel scrollInner = new ScrollPanel(); scrollInner.setAlwaysShowScrollBars(true); scrollInner.setPixelSize(400, 400); scrollInner.setWidget(grid); ScrollPanel scrollOuter = new ScrollPanel(); scrollOuter.add(scrollInner); scrollOuter.setAlwaysShowScrollBars(true); scrollOuter.setPixelSize(600, 200); outer.add(scrollOuter); scrollInner.setScrollPosition(100); scrollInner.setHorizontalScrollPosition(100); }
From source file:edu.caltech.ipac.firefly.ui.GwtUtil.java
/** * Cause the ScrollPanel to set it scroll bars so the widget it is showing is centered * * @param sp the scrollPanel// www . j av a 2 s . c o m */ public static void centerScrollPanel(ScrollPanel sp) { Element el = sp.getElement(); int sw = DOM.getElementPropertyInt(el, "scrollWidth"); int sh = DOM.getElementPropertyInt(el, "scrollHeight"); int w = sp.getOffsetWidth(); int h = sp.getOffsetHeight(); sp.setScrollPosition((sh - h) / 2); sp.setHorizontalScrollPosition((sw - w) / 2); }
From source file:org.rstudio.studio.client.workbench.views.vcs.git.dialog.GitReviewPanel.java
License:Open Source License
private void scrollBy(ScrollPanel scrollPanel, int vscroll, int hscroll) { if (vscroll != 0) { scrollPanel.setVerticalScrollPosition(Math.max(0, scrollPanel.getVerticalScrollPosition() + vscroll)); }/* ww w .j a v a 2 s. com*/ if (hscroll != 0) { scrollPanel .setHorizontalScrollPosition(Math.max(0, scrollPanel.getHorizontalScrollPosition() + hscroll)); } }