Package javax.swing

Examples of javax.swing.JViewport




  public void scrollBy(int deltaX, int deltaY) {
    if (getParent() instanceof JViewport) {
      JViewport viewport = (JViewport) getParent();
      Point oldViewPos = viewport.getViewPosition();
      Point viewPos = new Point(oldViewPos.x, oldViewPos.y);
      if (deltaX!=0){
        viewPos.x += deltaX;
        int maxX = getWidth() - viewport.getWidth();

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

        viewPos.y = Math.min(viewPos.y, maxY);
        viewPos.y = Math.max(viewPos.y, 0);
      }
      if (viewPos.equals(oldViewPos)) {
        stopAutoScroll();
      } else {
        viewport.setViewPosition(viewPos);
      }
    }
  }
View Full Code Here


  }


  private void handleMouseExited(MouseEvent evt) {
    if (Settings.propProgramTableMouseOver.getBoolean()) {
      JViewport viewport = (JViewport) getParent();
      if (((mPopupMenu == null) || (!mPopupMenu.isVisible())) && !viewport.getViewRect().contains(evt.getPoint())) {
        repaintCell(mMouseMatrix);
        mMouse = null;
        mMouseMatrix = new Point(-1, -1);
      }
    }
View Full Code Here

      if (tooltip != null && tooltip.length() > 0) {
        buffer.append(tooltip);
      }

      // if program is partially not visible then show the title as tooltip
      final JViewport viewport = MainFrame.getInstance()
          .getProgramTableScrollPane().getViewport();
      Point viewPos = viewport.getViewPosition();
      Dimension viewSize = viewport.getSize();
      final Program program = panel.getProgram();
      if ((currY < viewPos.y)
          || (panelIndex.x * mColumnWidth + panel.getTitleX() < viewPos.x)
          || ((panelIndex.x + 1) * mColumnWidth - 1 > viewPos.x
              + viewSize.width)) {
View Full Code Here

    final JScrollPane js = new JScrollPane(m_OutText);
    p3.add(js, BorderLayout.CENTER);
    js.getViewport().addChangeListener(new ChangeListener() {
      private int lastHeight;
      public void stateChanged(ChangeEvent e) {
  JViewport vp = (JViewport)e.getSource();
  int h = vp.getViewSize().height;
  if (h != lastHeight) { // i.e. an addition not just a user scrolling
    lastHeight = h;
    int x = h - vp.getExtentSize().height;
    vp.setViewPosition(new Point(0, x));
  }
      }
    });   

    JPanel mondo = new JPanel();
View Full Code Here

    final JScrollPane js = new JScrollPane(m_OutText);
    p3.add(js, BorderLayout.CENTER);
    js.getViewport().addChangeListener(new ChangeListener() {
      private int lastHeight;
      public void stateChanged(ChangeEvent e) {
  JViewport vp = (JViewport)e.getSource();
  int h = vp.getViewSize().height;
  if (h != lastHeight) { // i.e. an addition not just a user scrolling
    lastHeight = h;
    int x = h - vp.getExtentSize().height;
    vp.setViewPosition(new Point(0, x));
  }
      }
    });
   
    JPanel mondo = new JPanel();
View Full Code Here

    createActions(controller, preferences);
   
    // Layout components
    JComponent furnitureLibraryView = (JComponent)controller.getFurnitureLibraryController().getView();
    JScrollPane furnitureLibraryScrollPane = new JScrollPane(furnitureLibraryView);
    JViewport viewport = furnitureLibraryScrollPane.getViewport();
    viewport.setTransferHandler(furnitureLibraryView.getTransferHandler());   
    JPopupMenu furnitureLibraryPopupMenu = createFurnitureLibraryPopupMenu(preferences, controller);
    furnitureLibraryView.setComponentPopupMenu(furnitureLibraryPopupMenu);
    viewport.setComponentPopupMenu(furnitureLibraryPopupMenu);
    getContentPane().add(furnitureLibraryScrollPane);
    getContentPane().add(createToolBar(preferences, controller), BorderLayout.NORTH);
   
    // Map Enter accelerator of furniture library to furniture modification action
    furnitureLibraryView.getInputMap().put(KeyStroke.getKeyStroke("ENTER"), ActionType.MODIFY_FURNITURE);
View Full Code Here

  /**
   * Override to get no Line-Wraps
   */
  public boolean getScrollableTracksViewportWidth() {
    if (getParent() instanceof JViewport) {
      JViewport port = (JViewport) getParent();
      TextUI textUI = getUI();
      int w = port.getWidth();
      textUI.getMinimumSize(this);
      textUI.getMaximumSize(this);
      Dimension pref = textUI.getPreferredSize(this);
     
      if ((w >= pref.width)) {
View Full Code Here

    private void applyScrollableUnitIncrement(int increment) {
        try {
            // Fix for the continuous scrolling issue (not very elegant..)
           
            JViewport vp = (JViewport) getParent();
            JScrollPane sp = (JScrollPane) vp.getParent();
            JScrollBar sb = sp.getVerticalScrollBar();
           
            if (increment != 0)
                sb.setUnitIncrement(increment);
        } catch (Exception e) {
View Full Code Here

            viewerContext.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 LOCAL_PAGE :
      {
        int page = viewerContext.getPageIndex() + 1;
        if (hyperlink.getHyperlinkPage() != null)
        {
          page = hyperlink.getHyperlinkPage().intValue();
        }

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

        break;
      }
View Full Code Here

    // Add your handling code here:

    Container container = pnlInScroll.getParent();
    if (container instanceof JViewport)
    {
      JViewport viewport = (JViewport) container;
      Point point = viewport.getViewPosition();
      int newX = point.x - (evt.getX() - downX);
      int newY = point.y - (evt.getY() - downY);

      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));
    }
  }//GEN-LAST:event_pnlLinksMouseDragged
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.