Package javax.swing

Examples of javax.swing.Scrollable


    // compute the insets
    // TBD - the thing with the scrollable
    Insets i = new Insets(0, 0, 0, 0);
    if (c instanceof Scrollable) {
      Scrollable s = (Scrollable) c;
      i.left =
        s.getScrollableUnitIncrement(
          visible,
          SwingConstants.HORIZONTAL,
          1);
      i.top =
        s.getScrollableUnitIncrement(
          visible,
          SwingConstants.VERTICAL,
          1);
      i.right =
        s.getScrollableUnitIncrement(
          visible,
          SwingConstants.HORIZONTAL,
          -1);
      i.bottom =
        s.getScrollableUnitIncrement(
          visible,
          SwingConstants.VERTICAL,
          -1);
    }
View Full Code Here


                                : new Dimension(0,0);

        boolean viewTracksViewportWidth = false;
        boolean viewTracksViewportHeight = false;
        boolean isEmpty = (availR.width < 0 || availR.height < 0);
        Scrollable sv;
            // Don't bother checking the Scrollable methods if there is no room
            // for the viewport, we aren't going to show any scrollbars in this
            // case anyway.
        if (!isEmpty && view instanceof Scrollable) {
            sv = (Scrollable)view;
            viewTracksViewportWidth = sv.getScrollableTracksViewportWidth();
            viewTracksViewportHeight = sv.getScrollableTracksViewportHeight();
        }
        else {
            sv = null;
        }

        /* If there's a vertical scrollbar and we need one, allocate
         * space for it (we'll make it visible later). A vertical
         * scrollbar is considered to be fixed width, arbitrary height.
         */

        Rectangle vsbR = new Rectangle(0, availR.y - vpbInsets.top, 0, 0);

        boolean vsbNeeded;
            if (isEmpty) {
                vsbNeeded = false;
            }
        else if (vsbPolicy == VERTICAL_SCROLLBAR_ALWAYS) {
            vsbNeeded = true;
        }
        else if (vsbPolicy == VERTICAL_SCROLLBAR_NEVER) {
            vsbNeeded = false;
        }
        else // vsbPolicy == VERTICAL_SCROLLBAR_AS_NEEDED
            vsbNeeded = !viewTracksViewportHeight && (viewPrefSize.height > extentSize.height);
        }


        if ((vsb != null) && vsbNeeded) {
            adjustForVSB(true, availR, vsbR, vpbInsets, leftToRight);
            extentSize = viewport.toViewCoordinates(availR.getSize());
        }

        /* If there's a horizontal scrollbar and we need one, allocate
         * space for it (we'll make it visible later). A horizontal
         * scrollbar is considered to be fixed height, arbitrary width.
         */

        Rectangle hsbR = new Rectangle(availR.x - vpbInsets.left, 0, 0, 0);
        boolean hsbNeeded;
            if (isEmpty) {
                hsbNeeded = false;
            }
        else if (hsbPolicy == HORIZONTAL_SCROLLBAR_ALWAYS) {
            hsbNeeded = true;
        }
        else if (hsbPolicy == HORIZONTAL_SCROLLBAR_NEVER) {
            hsbNeeded = false;
        }
        else // hsbPolicy == HORIZONTAL_SCROLLBAR_AS_NEEDED
            hsbNeeded = !viewTracksViewportWidth && (viewPrefSize.width > extentSize.width);
        }

        if ((hsb != null) && hsbNeeded) {
            adjustForHSB(true, availR, hsbR, vpbInsets);

            /* If we added the horizontal scrollbar then we've implicitly
             * reduced  the vertical space available to the viewport.
             * As a consequence we may have to add the vertical scrollbar,
             * if that hasn't been done so already.  Of course we
             * don't bother with any of this if the vsbPolicy is NEVER.
             */
            if ((vsb != null) && !vsbNeeded &&
            (vsbPolicy != VERTICAL_SCROLLBAR_NEVER)) {

                extentSize = viewport.toViewCoordinates(availR.getSize());
                vsbNeeded = viewPrefSize.height > extentSize.height;

                if (vsbNeeded) {
                    adjustForVSB(true, availR, vsbR, vpbInsets, leftToRight);
                }
            }
        }

        /* Set the size of the viewport first, and then recheck the Scrollable
         * methods. Some components base their return values for the Scrollable
         * methods on the size of the Viewport, so that if we don't
         * ask after resetting the bounds we may have gotten the wrong
         * answer.
         */

        if (viewport != null) {
            viewport.setBounds(availR);

            if (sv != null) {
            extentSize = viewport.toViewCoordinates(availR.getSize());

            boolean oldHSBNeeded = hsbNeeded;
            boolean oldVSBNeeded = vsbNeeded;
            viewTracksViewportWidth = sv.
                                        getScrollableTracksViewportWidth();
            viewTracksViewportHeight = sv.
                                        getScrollableTracksViewportHeight();
            if (vsb != null && vsbPolicy == VERTICAL_SCROLLBAR_AS_NEEDED) {
                boolean newVSBNeeded = !viewTracksViewportHeight &&
                                    (viewPrefSize.height > extentSize.height);
                if (newVSBNeeded != vsbNeeded) {
View Full Code Here

                                : new Dimension(0,0);

        boolean viewTracksViewportWidth = false;
        boolean viewTracksViewportHeight = false;
        boolean isEmpty = (availR.width < 0 || availR.height < 0);
        Scrollable sv;
            // Don't bother checking the Scrollable methods if there is no room
            // for the viewport, we aren't going to show any scrollbars in this
            // case anyway.
        if (!isEmpty && view instanceof Scrollable) {
            sv = (Scrollable)view;
            viewTracksViewportWidth = sv.getScrollableTracksViewportWidth();
            viewTracksViewportHeight = sv.getScrollableTracksViewportHeight();
        }
        else {
            sv = null;
        }

        /* If there's a vertical scrollbar and we need one, allocate
         * space for it (we'll make it visible later). A vertical
         * scrollbar is considered to be fixed width, arbitrary height.
         */

        Rectangle vsbR = new Rectangle(0, availR.y - vpbInsets.top, 0, 0);

        boolean vsbNeeded;
            if (isEmpty) {
                vsbNeeded = false;
            }
        else if (vsbPolicy == VERTICAL_SCROLLBAR_ALWAYS) {
            vsbNeeded = true;
        }
        else if (vsbPolicy == VERTICAL_SCROLLBAR_NEVER) {
            vsbNeeded = false;
        }
        else // vsbPolicy == VERTICAL_SCROLLBAR_AS_NEEDED
            vsbNeeded = !viewTracksViewportHeight && (viewPrefSize.height > extentSize.height);
        }


        if ((vsb != null) && vsbNeeded) {
            adjustForVSB(true, availR, vsbR, vpbInsets, leftToRight);
            extentSize = viewport.toViewCoordinates(availR.getSize());
        }

        /* If there's a horizontal scrollbar and we need one, allocate
         * space for it (we'll make it visible later). A horizontal
         * scrollbar is considered to be fixed height, arbitrary width.
         */

        Rectangle hsbR = new Rectangle(availR.x - vpbInsets.left, 0, 0, 0);
        boolean hsbNeeded;
            if (isEmpty) {
                hsbNeeded = false;
            }
        else if (hsbPolicy == HORIZONTAL_SCROLLBAR_ALWAYS) {
            hsbNeeded = true;
        }
        else if (hsbPolicy == HORIZONTAL_SCROLLBAR_NEVER) {
            hsbNeeded = false;
        }
        else // hsbPolicy == HORIZONTAL_SCROLLBAR_AS_NEEDED
            hsbNeeded = !viewTracksViewportWidth && (viewPrefSize.width > extentSize.width);
        }

        if ((hsb != null) && hsbNeeded) {
            adjustForHSB(true, availR, hsbR, vpbInsets);

            /* If we added the horizontal scrollbar then we've implicitly
             * reduced  the vertical space available to the viewport.
             * As a consequence we may have to add the vertical scrollbar,
             * if that hasn't been done so already.  Of course we
             * don't bother with any of this if the vsbPolicy is NEVER.
             */
            if ((vsb != null) && !vsbNeeded &&
            (vsbPolicy != VERTICAL_SCROLLBAR_NEVER)) {

                extentSize = viewport.toViewCoordinates(availR.getSize());
                vsbNeeded = viewPrefSize.height > extentSize.height;

                if (vsbNeeded) {
                    adjustForVSB(true, availR, vsbR, vpbInsets, leftToRight);
                }
            }
        }

        /* Set the size of the viewport first, and then recheck the Scrollable
         * methods. Some components base their return values for the Scrollable
         * methods on the size of the Viewport, so that if we don't
         * ask after resetting the bounds we may have gotten the wrong
         * answer.
         */

        if (viewport != null) {
            viewport.setBounds(availR);

            if (sv != null) {
            extentSize = viewport.toViewCoordinates(availR.getSize());

            boolean oldHSBNeeded = hsbNeeded;
            boolean oldVSBNeeded = vsbNeeded;
            viewTracksViewportWidth = sv.
                                        getScrollableTracksViewportWidth();
            viewTracksViewportHeight = sv.
                                        getScrollableTracksViewportHeight();
            if (vsb != null && vsbPolicy == VERTICAL_SCROLLBAR_AS_NEEDED) {
                boolean newVSBNeeded = !viewTracksViewportHeight &&
                                    (viewPrefSize.height > extentSize.height);
                if (newVSBNeeded != vsbNeeded) {
View Full Code Here

                                : new Dimension(0,0);

        boolean viewTracksViewportWidth = false;
        boolean viewTracksViewportHeight = false;
        boolean isEmpty = (availR.width < 0 || availR.height < 0);
        Scrollable sv;
            // Don't bother checking the Scrollable methods if there is no room
            // for the viewport, we aren't going to show any scrollbars in this
            // case anyway.
        if (!isEmpty && view instanceof Scrollable) {
            sv = (Scrollable)view;
            viewTracksViewportWidth = sv.getScrollableTracksViewportWidth();
            viewTracksViewportHeight = sv.getScrollableTracksViewportHeight();
        }
        else {
            sv = null;
        }

        /* If there's a vertical scrollbar and we need one, allocate
         * space for it (we'll make it visible later). A vertical
         * scrollbar is considered to be fixed width, arbitrary height.
         */

        Rectangle vsbR = new Rectangle(0, availR.y - vpbInsets.top, 0, 0);

        boolean vsbNeeded;
            if (isEmpty) {
                vsbNeeded = false;
            }
        else if (vsbPolicy == VERTICAL_SCROLLBAR_ALWAYS) {
            vsbNeeded = true;
        }
        else if (vsbPolicy == VERTICAL_SCROLLBAR_NEVER) {
            vsbNeeded = false;
        }
        else // vsbPolicy == VERTICAL_SCROLLBAR_AS_NEEDED
            vsbNeeded = !viewTracksViewportHeight && (viewPrefSize.height > extentSize.height);
        }


        if ((vsb != null) && vsbNeeded) {
            adjustForVSB(true, availR, vsbR, vpbInsets, leftToRight);
            extentSize = viewport.toViewCoordinates(availR.getSize());
        }

        /* If there's a horizontal scrollbar and we need one, allocate
         * space for it (we'll make it visible later). A horizontal
         * scrollbar is considered to be fixed height, arbitrary width.
         */

        Rectangle hsbR = new Rectangle(availR.x - vpbInsets.left, 0, 0, 0);
        boolean hsbNeeded;
            if (isEmpty) {
                hsbNeeded = false;
            }
        else if (hsbPolicy == HORIZONTAL_SCROLLBAR_ALWAYS) {
            hsbNeeded = true;
        }
        else if (hsbPolicy == HORIZONTAL_SCROLLBAR_NEVER) {
            hsbNeeded = false;
        }
        else // hsbPolicy == HORIZONTAL_SCROLLBAR_AS_NEEDED
            hsbNeeded = !viewTracksViewportWidth && (viewPrefSize.width > extentSize.width);
        }

        if ((hsb != null) && hsbNeeded) {
            adjustForHSB(true, availR, hsbR, vpbInsets);

            /* If we added the horizontal scrollbar then we've implicitly
             * reduced  the vertical space available to the viewport.
             * As a consequence we may have to add the vertical scrollbar,
             * if that hasn't been done so already.  Of course we
             * don't bother with any of this if the vsbPolicy is NEVER.
             */
            if ((vsb != null) && !vsbNeeded &&
            (vsbPolicy != VERTICAL_SCROLLBAR_NEVER)) {

                extentSize = viewport.toViewCoordinates(availR.getSize());
                vsbNeeded = viewPrefSize.height > extentSize.height;

                if (vsbNeeded) {
                    adjustForVSB(true, availR, vsbR, vpbInsets, leftToRight);
                }
            }
        }

        /* Set the size of the viewport first, and then recheck the Scrollable
         * methods. Some components base their return values for the Scrollable
         * methods on the size of the Viewport, so that if we don't
         * ask after resetting the bounds we may have gotten the wrong
         * answer.
         */

        if (viewport != null) {
            viewport.setBounds(availR);

            if (sv != null) {
            extentSize = viewport.toViewCoordinates(availR.getSize());

            boolean oldHSBNeeded = hsbNeeded;
            boolean oldVSBNeeded = vsbNeeded;
            viewTracksViewportWidth = sv.
                                        getScrollableTracksViewportWidth();
            viewTracksViewportHeight = sv.
                                        getScrollableTracksViewportHeight();
            if (vsb != null && vsbPolicy == VERTICAL_SCROLLBAR_AS_NEEDED) {
                boolean newVSBNeeded = !viewTracksViewportHeight &&
                                    (viewPrefSize.height > extentSize.height);
                if (newVSBNeeded != vsbNeeded) {
View Full Code Here

    else if(horizontalDiffRight < DELTA)
      {horizontal = 1;}
   
    if(comp instanceof Scrollable)
    {
      final Scrollable scrollable = (Scrollable)comp;
      vertical *= scrollable.getScrollableUnitIncrement(rect, SwingConstants.VERTICAL, vertical);
      horizontal *= scrollable.getScrollableUnitIncrement(rect, SwingConstants.HORIZONTAL, horizontal);
    }
    else
    {
      vertical *= DEFAULT_INCREMENT;
      horizontal *= DEFAULT_INCREMENT;
View Full Code Here

        Rectangle newVisible = new Rectangle(visible.x, visible.y, visible.width, visible.height);
       
        // We know that this cast must succeed, since the constructors
        // throw IllegalArgumentException if the component is not a
        // Scrollable.
        Scrollable s = (Scrollable) comp;
       
        // If the mouse is not over the tree at this time, ignore
        // the timer event.
        if (mouse == null) {
            return;
        }

        // If we're in the autoscroll strip at the left or the right, adjust
        // the x position. We increase the x-amount to scroll, because the amount
        // that JTree tells us to scroll is too small. (Per conversation with
        // Tom Dayton, 2010-06-15. The factor to increase by was empirically
        // arrived at by Mark Rose on 2010-06-15.)
        if (mouse.x < visible.x + AUTOSCROLL_BORDER_SIZE) {
            newVisible.x = max(0, visible.x - 3*s.getScrollableUnitIncrement(visible, SwingConstants.HORIZONTAL, -1));
        } else if (mouse.x > visible.x + visible.width - AUTOSCROLL_BORDER_SIZE) {
            newVisible.x = min(bounds.width - visible.width, visible.x + 3*s.getScrollableUnitIncrement(visible, SwingConstants.HORIZONTAL, 1));
        }

        // If we're in the autoscroll strip at the top or the bottom, adjust
        // the y position.
        if (mouse.y < visible.y + AUTOSCROLL_BORDER_SIZE) {
            newVisible.y = max(0, visible.y - s.getScrollableUnitIncrement(visible, SwingConstants.VERTICAL, -1));
        } else if (mouse.y > visible.y + visible.height - AUTOSCROLL_BORDER_SIZE) {
            newVisible.y = min(bounds.height - visible.height, visible.y + s.getScrollableUnitIncrement(visible, SwingConstants.VERTICAL, 1));
        }
       
        // If we changed either x or y, then scroll the tree.
        if (!newVisible.equals(visible)) {
            comp.scrollRectToVisible(newVisible);
View Full Code Here

    // compute the insets
    // TBD - the thing with the scrollable
    Insets i = new Insets(0, 0, 0, 0);
    if (c instanceof Scrollable) {
      Scrollable s = (Scrollable) c;
      i.left =
        s.getScrollableUnitIncrement(
          visible,
          SwingConstants.HORIZONTAL,
          1);
      i.top =
        s.getScrollableUnitIncrement(
          visible,
          SwingConstants.VERTICAL,
          1);
      i.right =
        s.getScrollableUnitIncrement(
          visible,
          SwingConstants.HORIZONTAL,
          -1);
      i.bottom =
        s.getScrollableUnitIncrement(
          visible,
          SwingConstants.VERTICAL,
          -1);
    }
View Full Code Here

TOP

Related Classes of javax.swing.Scrollable

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.