Package javax.swing

Examples of javax.swing.JViewport


        //
        // ChangeListener: This is added to the vieport, and hsb/vsb models.
        //
        public void stateChanged(ChangeEvent e) {
            JViewport viewport = scrollpane.getViewport();

            if (viewport != null) {
                if (e.getSource() == viewport) {
                    viewportStateChanged(e);
                } else {
View Full Code Here


                    }
                }
            } else if ("componentOrientation" == propertyName) {
                if (source == scrollpane.getHorizontalScrollBar()) {
                    JScrollBar hsb = scrollpane.getHorizontalScrollBar();
                    JViewport viewport = scrollpane.getViewport();
                    Point p = viewport.getViewPosition();
                    if (scrollpane.getComponentOrientation().isLeftToRight()) {
                        p.x = hsb.getValue();
                    } else {
                        p.x = viewport.getViewSize().width - viewport.getExtentSize().width - hsb.getValue();
                    }
                    viewport.setViewPosition(p);
                }
            }
        }
View Full Code Here

        context.dispose();
    }

    protected void paint(SeaGlassContext context, Graphics g) {
        JComponent c = context.getComponent();
        JViewport viewport = (JViewport) c;
        if (c.isOpaque()) {
            Component view = viewport.getView();
            Object ui = (view == null) ? null : invokeGetter(view, "getUI", null);
            if (ui instanceof ViewportPainter) {
                ((ViewportPainter) ui).paintViewport(context, g, viewport);
            } else {
                if (viewport.getView() != null) {
                    g.setColor(viewport.getView().getBackground());
                    g.fillRect(0, 0, c.getWidth(), c.getHeight());
                }
            }
        }
    }
View Full Code Here

            break;
        }
    }

    private void paintBackground(Graphics2D g, JComponent c, int width, int height) {
        JViewport viewport = ((JScrollPane)c).getViewport();
        if (viewport.isOpaque()) {
            Shape s = shapeGenerator.createRoundRectangle(0, 0, width - 1, height - 1, CornerSize.BORDER);
            g.setPaint(viewport.getBackground());
            g.fill(s);
        }
    }
View Full Code Here

  {
    Dimension preferredSize = painter.getPreferredSize();

    if( getParent() instanceof JViewport )
    {
      JViewport viewport = ( JViewport )getParent();
      Dimension size = viewport.getSize();

      preferredSize = new Dimension( ( int )( preferredSize.getWidth() < size.getWidth() ? size.getWidth()
          : preferredSize.getWidth() ), ( int )( preferredSize.getHeight() < size.getHeight() ? size.getHeight()
          : preferredSize.getHeight() ) );
    }
View Full Code Here

    this( comp, new Insets( AUTOSCROLL_MARGIN, AUTOSCROLL_MARGIN, AUTOSCROLL_MARGIN, AUTOSCROLL_MARGIN ) );
  }

  public void autoscroll( Point cursorLoc )
  {
    JViewport viewport = getViewport();
    if( viewport == null )
      return;
    Point viewPos = viewport.getViewPosition();
    int viewHeight = viewport.getExtentSize().height;
    int viewWidth = viewport.getExtentSize().width;

    // resolve scrolling
    if( ( cursorLoc.y - viewPos.y ) < insets.top )
    { // scroll up
      viewport.setViewPosition( new Point( viewPos.x, Math.max( viewPos.y - scrollUnits.top, 0 ) ) );
    }
    else if( ( viewPos.y + viewHeight - cursorLoc.y ) < insets.bottom )
    { // scroll down
      viewport.setViewPosition( new Point( viewPos.x, Math.min( viewPos.y + scrollUnits.bottom, comp.getHeight()
          - viewHeight ) ) );
    }
    else if( ( cursorLoc.x - viewPos.x ) < insets.left )
    { // scroll left
      viewport.setViewPosition( new Point( Math.max( viewPos.x - scrollUnits.left, 0 ), viewPos.y ) );
    }
    else if( ( viewPos.x + viewWidth - cursorLoc.x ) < insets.right )
    { // scroll right
      viewport.setViewPosition( new Point( Math.min( viewPos.x + scrollUnits.right, comp.getWidth() - viewWidth ),
          viewPos.y ) );
    }
  }
View Full Code Here

    }
   
    hideCurrentPopup();
    LayoutThumbnail layout = new LayoutThumbnail();
    layout.setCircuit(circuitState, ports);
    JViewport owner = canvasPane.getViewport();
    Point ownerLoc = owner.getLocationOnScreen();
    Dimension ownerDim = owner.getSize();
    Dimension layoutDim = layout.getPreferredSize();
    int x = ownerLoc.x + Math.max(0, ownerDim.width - layoutDim.width - 5);
    int y = ownerLoc.y + Math.max(0, ownerDim.height - layoutDim.height - 5);
    PopupFactory factory = PopupFactory.getSharedInstance();
    Popup popup = factory.getPopup(canvasPane.getViewport(), layout, x, y);
View Full Code Here

    mNextBt.addActionListener(this);
  }
 
  public void scrollBy(int deltaX, int deltaY) {
    if (mPreviewComponent.getParent() instanceof JViewport) {
      JViewport viewport = (JViewport) mPreviewComponent.getParent();
      Point viewPos = viewport.getViewPosition();

      if (deltaX!=0){
        viewPos.x += deltaX;

        int maxX = mPreviewComponent.getWidth() - viewport.getWidth();

        viewPos.x = Math.min(viewPos.x, maxX);
        viewPos.x = Math.max(viewPos.x, 0);

        viewport.setViewPosition(viewPos);
      }

      if (deltaY !=0){
        viewPos.y += deltaY;
        int maxY = mPreviewComponent.getHeight() - viewport.getHeight();
        viewPos.y = Math.min(viewPos.y, maxY);
        viewPos.y = Math.max(viewPos.y, 0);

        viewport.setViewPosition(viewPos);
      }
    }
  }
View Full Code Here

        assertTrue(ui.nonContinuousLayoutDivider == component);
    }

    public void testAddComponentToLayout() throws Exception {
        assertEquals(3, ui.layoutManager.components.length);
        JViewport viewport = new JViewport();
        ui.layoutManager.addLayoutComponent(JSplitPane.BOTTOM, viewport);
        assertFalse(ui.layoutManager.components[0] == viewport);
        assertTrue(ui.layoutManager.components[1] == viewport);
        assertFalse(ui.layoutManager.components[2] == viewport);
        ui.layoutManager.addLayoutComponent(JSplitPane.BOTTOM, new JButton());
View Full Code Here

            refreshPage();
          }
          Container container = pnlInScroll.getParent();
          if (container instanceof JViewport)
          {
            JViewport viewport = (JViewport) container;

            int newX = (int)(anchorIndex.getElementAbsoluteX() * realZoom);
            int newY = (int)(anchorIndex.getElementAbsoluteY() * realZoom);

            int maxX = pnlInScroll.getWidth() - viewport.getWidth();
            int maxY = pnlInScroll.getHeight() - viewport.getHeight();

            if (newX < 0)
            {
              newX = 0;
            }
            if (newX > maxX)
            {
              newX = maxX;
            }
            if (newY < 0)
            {
              newY = 0;
            }
            if (newY > maxY)
            {
              newY = maxY;
            }

            viewport.setViewPosition(new Point(newX, newY));
          }
        }

        break;
      }
      case JRHyperlink.HYPERLINK_TYPE_LOCAL_PAGE :
      {
        int page = pageIndex + 1;
        if (hyperlink.getHyperlinkPage() != null)
        {
          page = hyperlink.getHyperlinkPage().intValue();
        }

        if (page >= 1 && page <= jasperPrint.getPages().size() && page != pageIndex + 1)
        {
          setPageIndex(page - 1);
          refreshPage();
          Container container = pnlInScroll.getParent();
          if (container instanceof JViewport)
          {
            JViewport viewport = (JViewport) container;
            viewport.setViewPosition(new Point(0, 0));
          }
        }

        break;
      }
View Full Code Here

TOP

Related Classes of javax.swing.JViewport

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.