List of usage examples for javax.swing JScrollBar getMinimum
public int getMinimum()
From source file:Main.java
/** * Scrolls the given component to its top or bottom. * Useful for implementing behavior like in Apple's Mail where home/end in the list cause scrolling in the text. *///w ww . j a v a2s. c o m public static void scrollToExtremity(JComponent c, boolean top) { JScrollBar scrollBar = ((JScrollPane) SwingUtilities.getAncestorOfClass(JScrollPane.class, c)) .getVerticalScrollBar(); scrollBar.setValue(top ? scrollBar.getMinimum() : scrollBar.getMaximum()); }
From source file:Main.java
/** * Scrolls scroll pane to the top left corner. *//*from w ww. j a v a2 s . c o m*/ public static void scrollToTop(final JScrollPane scrollPane) { JScrollBar verticalScrollBar = scrollPane.getVerticalScrollBar(); JScrollBar horizontalScrollBar = scrollPane.getHorizontalScrollBar(); verticalScrollBar.setValue(verticalScrollBar.getMinimum()); horizontalScrollBar.setValue(horizontalScrollBar.getMinimum()); }
From source file:Main.java
/** * Scrolls the given component by its unit or block increment in the given direction (actually a scale factor, so use +1 or -1). * Useful for implementing behavior like in Apple's Mail where page up/page down in the list cause scrolling in the text. *///from ww w .java2 s . c o m public static void scroll(JComponent c, boolean byBlock, int direction) { JScrollPane scrollPane = (JScrollPane) SwingUtilities.getAncestorOfClass(JScrollPane.class, c); JScrollBar scrollBar = scrollPane.getVerticalScrollBar(); int increment = byBlock ? scrollBar.getBlockIncrement(direction) : scrollBar.getUnitIncrement(direction); int newValue = scrollBar.getValue() + direction * increment; newValue = Math.min(newValue, scrollBar.getMaximum()); newValue = Math.max(newValue, scrollBar.getMinimum()); scrollBar.setValue(newValue); }
From source file:Main.java
public static void scrollByBlock(JScrollBar scrollbar, int direction) { // This method is called from BasicScrollPaneUI to implement wheel // scrolling, and also from scrollByBlock(). int oldValue = scrollbar.getValue(); int blockIncrement = scrollbar.getBlockIncrement(direction); int delta = blockIncrement * ((direction > 0) ? +1 : -1); int newValue = oldValue + delta; // Check for overflow. if (delta > 0 && newValue < oldValue) { newValue = scrollbar.getMaximum(); } else if (delta < 0 && newValue > oldValue) { newValue = scrollbar.getMinimum(); }/*from w ww . j a v a2 s . co m*/ scrollbar.setValue(newValue); }
From source file:ButtonCornerSample.java
public void actionPerformed(ActionEvent actionEvent) { JScrollBar verticalScrollBar = scrollPane.getVerticalScrollBar(); JScrollBar horizontalScrollBar = scrollPane.getHorizontalScrollBar(); verticalScrollBar.setValue(verticalScrollBar.getMinimum()); horizontalScrollBar.setValue(horizontalScrollBar.getMinimum()); }
From source file:com.commander4j.util.JUtility.java
public static void scrolltoHomePosition(JScrollPane jScrollPane1) { JScrollBar verticalScrollBar = jScrollPane1.getVerticalScrollBar(); JScrollBar horizontalScrollBar = jScrollPane1.getHorizontalScrollBar(); verticalScrollBar.setValue(verticalScrollBar.getMinimum()); horizontalScrollBar.setValue(horizontalScrollBar.getMinimum()); }
From source file:edu.brown.gui.CatalogViewer.java
/** * Scroll the attributes pane to the top *///from w ww. jav a 2s . c o m protected void scrollTextInfoToTop() { JScrollBar verticalScrollBar = this.textInfoScroller.getVerticalScrollBar(); JScrollBar horizontalScrollBar = this.textInfoScroller.getHorizontalScrollBar(); verticalScrollBar.setValue(verticalScrollBar.getMinimum()); horizontalScrollBar.setValue(horizontalScrollBar.getMinimum()); // System.err.println("VERTICAL=" + verticalScrollBar.getValue() + ", HORIZONTAL=" + horizontalScrollBar.getValue()); }
From source file:com.pingtel.sipviewer.SIPViewerFrame.java
protected void applyData(Vector vData) { m_model.clear();/*w w w. ja v a 2 s . c om*/ if (m_sortBranchNodes) { // Do some magic to adjust for the case where the response // shows up just before the request. SipBranchData current = null; SipBranchData previous = null; String strCurrentBranchId; String strPreviousBranchId; for (int i = vData.size() - 1; i > 0; i--) { current = (SipBranchData) vData.elementAt(i); strCurrentBranchId = current.getThisBranchId(); previous = (SipBranchData) vData.elementAt(i - 1); strPreviousBranchId = current.getThisBranchId(); if ((strCurrentBranchId != null) && (strCurrentBranchId.length() > 0) && (strPreviousBranchId != null) && (strPreviousBranchId.length() > 0) && (strCurrentBranchId.equals(strPreviousBranchId)) && (current.isRequest()) && (!previous.isRequest()) && (current.getMethod() != "ack")) { vData.set(i, previous); vData.set(i - 1, current); System.out.println("Req/Resp swapped for branchID: " + strCurrentBranchId); } } } SipBranchData data = null; // loop over all the data elements and add them // to the model for (int i = 0; i < vData.size(); i++) { data = (SipBranchData) vData.elementAt(i); // pass in the for loop index since it is used // to set the displayIndex of each message, this // displayIndex is used to determine where the // message is displayed vertically and weather // it is visible or not (displayIndex of // -1 is invisible) addEntryToModel(data, i); } // Reset the scroll bar to the top. JScrollBar scroll = m_scrollPane.getVerticalScrollBar(); scroll.setValue(scroll.getMinimum()); // Revalidate to make sure the drawing pane is resized to match the // data. m_body.revalidate(); }
From source file:edu.purdue.cc.bionet.ui.GraphVisualizer.java
/** * Centers the graph in the display./*w w w. j a v a 2 s .com*/ */ public void center() { // toggle the scrollbars back and forth to center the image JScrollBar sb = scrollPane.getHorizontalScrollBar(); sb.setValue(sb.getMaximum()); sb.setValue(sb.getMinimum()); sb.setValue((sb.getMaximum() + sb.getMinimum()) / 2); sb = scrollPane.getVerticalScrollBar(); sb.setValue(sb.getMaximum()); sb.setValue(sb.getMinimum()); sb.setValue((sb.getMaximum() + sb.getMinimum()) / 2); }
From source file:org.forester.archaeopteryx.ControlPanel.java
void zoomOutY(final float factor) { final TreePanel treepanel = getMainPanel().getCurrentTreePanel(); treepanel.multiplyUrtFactor(0.9f);/*from w ww .jav a2 s . com*/ if ((treepanel.getYdistance() * factor) > 0.0) { final JScrollBar sb = getMainPanel().getCurrentScrollPane().getVerticalScrollBar(); final double x = (sb.getMaximum() - sb.getMinimum()) / (sb.getValue() + (sb.getVisibleAmount() / 2.0)); treepanel.setYdistance((treepanel.getYdistance() * factor)); getMainPanel().adjustJScrollPane(); treepanel.resetPreferredSize(); getMainPanel().getCurrentScrollPane().getViewport().validate(); sb.setValue(ForesterUtil .roundToInt(((sb.getMaximum() - sb.getMinimum()) / x) - (sb.getVisibleAmount() / 2.0))); treepanel.resetPreferredSize(); treepanel.updateOvSizes(); } }