Package javax.swing

Examples of javax.swing.JViewport


                    _moveX = nx;
                    _moveY = ny;

                    // Compute the view coordinates that appear in the upper left hand corner of the viewport
                    JViewport viewPort = (JViewport)getParent();
                    Point viewpos = viewPort.getViewPosition();
                    Dimension viewDim = viewPort.getViewSize();
                    viewpos.x += dx;
                    viewpos.y += dy;
                    if (viewpos.x < 0){
                        viewpos.x = 0;
                    }
                    if ( viewpos.x > viewDim.width - viewPort.getWidth() ){
                        viewpos.x = viewDim.width - viewPort.getWidth();
                    }
                    if (viewpos.y < 0){
                        viewpos.y = 0;
                    }
                    if ( viewpos.y > viewDim.height - viewPort.getHeight() ){
                        viewpos.y = viewDim.height - viewPort.getHeight();
                    }
                    viewPort.setViewPosition(viewpos);

              
               
                } else {
                    int nx=(int)((double)e.getX()/_param.scale)-_param.xmargin;
View Full Code Here


            canProccessMouseWheelEvent = true;

            if ((oldZoom != newZoom) && (getParent() instanceof JViewport) ){
               
                //  Update view position regarding mouse position
                JViewport viewPort = (JViewport)getParent();
                Point viewpos = viewPort.getViewPosition();
      
                // Compute ratio to appy to view position
                double ratioX = ( e.getX() -  viewpos.x) / (double)( viewPort.getWidth());
                double ratioY = ( e.getY() -  viewpos.y) / (double)( viewPort.getHeight());

                // Find mouse position in new zoom view
               double  mousePosX = (e.getX()/ oldZoom) * newZoom;
               double  mousePosY = (e.getY()/ oldZoom) * newZoom;
               
                viewpos.x  =  (int) (mousePosX - viewPort.getWidth()* ratioX );
                viewpos.y  =  (int) (mousePosY - viewPort.getHeight() * ratioY);


                // Cannot  exceed component dimension
                if (viewpos.x < 0){
                    viewpos.x = 0;
                }
                if (viewpos.y < 0){
                    viewpos.y = 0;
                }
                Dimension viewDim = viewPort.getViewSize();
                if (viewpos.x + viewPort.getWidth() > viewDim.getWidth()){
                    viewpos.x = (int) (viewDim.getWidth() - viewPort.getWidth());
                }
                if (viewpos.y + viewPort.getHeight() > viewDim.getHeight()){
                    viewpos.y = (int) (viewDim.getHeight() - viewPort.getHeight());
                }

                viewPort.setViewPosition(viewpos);  
           
        }

        if (!canProccessMouseWheelEvent){  // dispatch event to parent
            getParent().dispatchEvent(e);
View Full Code Here

  public UserPropertiesEditor(Frame owner) {
    super(owner,true);
    chooser=null;
    getContentPane().setLayout(new BorderLayout());
    JScrollPane scroller = new JScrollPane();
    JViewport port = scroller.getViewport();
   
    doc=new PlainDocument();
    createTextArea();
    port.add(ui);
   
    undoHandler = new UndoHandler(new UndoManager());
    doc.addUndoableEditListener(undoHandler);
    ui.addCaretListener(this);
    setupActions();
View Full Code Here

    JTextArea ta=new JTextArea(name+id, 5 , 4);
    id++;
    JScrollPane scroller = new JScrollPane(
        JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
        JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    JViewport port = scroller.getViewport();
    port.add(ta);
   
    st.addElement(scroller, name, mode);
  }
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 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

    // 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

 
  public ScrollingPanel(Component component) {
    setLayout(new BorderLayout());
    north = new BasicArrowButton(BasicArrowButton.NORTH);
    south = new BasicArrowButton(BasicArrowButton.SOUTH);
    viewport = new JViewport();
    add(north, BorderLayout.NORTH);
    add(viewport, BorderLayout.CENTER);
    add(south, BorderLayout.SOUTH);
    viewport.setView(component);
    north.addActionListener(this);
View Full Code Here

 
      if (furnitureView instanceof Scrollable) {
        JScrollPane furnitureScrollPane = new HomeScrollPane(furnitureView);
        // Add a mouse listener that gives focus to furniture view when
        // user clicks in its viewport (tables don't spread vertically if their row count is too small)
        final JViewport viewport = furnitureScrollPane.getViewport();
        viewport.addMouseListener(
            new MouseAdapter() {
              @Override
              public void mouseClicked(MouseEvent ev) {
                viewport.getView().requestFocusInWindow();
              }
            });   
        Integer viewportY = (Integer)home.getVisualProperty(FURNITURE_VIEWPORT_Y_VISUAL_PROPERTY);
        if (viewportY != null) {
          viewport.setViewPosition(new Point(0, viewportY));
        }
        viewport.addChangeListener(new ChangeListener() {
            public void stateChanged(ChangeEvent ev) {
              controller.setVisualProperty(FURNITURE_VIEWPORT_Y_VISUAL_PROPERTY, viewport.getViewPosition().y);
            }
          });
        ((JViewport)furnitureView.getParent()).setComponentPopupMenu(furnitureViewPopup);
        furnitureView = furnitureScrollPane;
      }
View Full Code Here

        }
        // Add a listener to update rulers visibility in preferences
        preferences.addPropertyChangeListener(UserPreferences.Property.RULERS_VISIBLE,
            new RulersVisibilityChangeListener(this, planScrollPane, controller));
        // Restore viewport position if it exists
        final JViewport viewport = planScrollPane.getViewport();
        Integer viewportX = (Integer)home.getVisualProperty(PLAN_VIEWPORT_X_VISUAL_PROPERTY);
        Integer viewportY = (Integer)home.getVisualProperty(PLAN_VIEWPORT_Y_VISUAL_PROPERTY);
        if (viewportX != null && viewportY != null) {
          viewport.setViewPosition(new Point(viewportX, viewportY));
        }
        viewport.addChangeListener(new ChangeListener() {
            public void stateChanged(ChangeEvent ev) {
              Point viewportPosition = viewport.getViewPosition();
              controller.setVisualProperty(PLAN_VIEWPORT_X_VISUAL_PROPERTY, viewportPosition.x);
              controller.setVisualProperty(PLAN_VIEWPORT_Y_VISUAL_PROPERTY, viewportPosition.y);
            }
          });
        planView = planScrollPane;
View Full Code Here

    info.setEntry(entry);

    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
          JViewport vp = scrollPane.getViewport();
          if(vp != null) {
            vp.setViewPosition(new Point(0,0));
            scrollPane.setViewport(vp);
          }
          if(table != null && model !=  null) {
            int row = model.getEntries().indexOf(entry);
            Rectangle r = table.getCellRect(row, 0, true);
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.