Package javax.swing

Examples of javax.swing.JViewport


   
    final JScrollPane js = new JScrollPane(m_outText);
    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));
        }
      }
    });
   
    m_outputPane.setBorder(BorderFactory.createTitledBorder("Output/Visualization"));
View Full Code Here


    execute(new GuiTask() {
      @Override
      protected void executeInEDT() {
        scrollToViewTextField = new JTextField(10);
        JScrollPane scrollPane = new JScrollPane(VERTICAL_SCROLLBAR_ALWAYS, HORIZONTAL_SCROLLBAR_ALWAYS);
        JViewport viewport = scrollPane.getViewport();
        viewport.add(new JLabel("A Label"));
        viewport.add(scrollToViewTextField);
        scrollPane.setPreferredSize(new Dimension(50, 50));
        window.add(scrollPane);
      }
    });
  }
View Full Code Here

        Disposer.register(this, tableModel);
    }

    private double calculateScrollDistance() {
        JViewport viewport = scrollPane.getViewport();
        double mouseLocation = MouseInfo.getPointerInfo().getLocation().getX();
        double viewportLocation = viewport.getLocationOnScreen().getX();

        Point viewPosition = viewport.getViewPosition();
        double contentLocation = viewport.getView().getLocationOnScreen().getX();

        if (contentLocation < viewportLocation && mouseLocation < viewportLocation + 20) {
            scrollDistance = - Math.min(viewPosition.x, (viewportLocation - mouseLocation));
        } else {
            int viewportWidth = viewport.getWidth();
            int contentWidth = viewport.getView().getWidth();

            if (contentLocation + contentWidth > viewportLocation + viewportWidth && mouseLocation > viewportLocation + viewportWidth - 20) {
                scrollDistance = (mouseLocation - viewportLocation - viewportWidth);
            } else {
                scrollDistance = 0;
View Full Code Here

        public void run() {
            if (scrollPane != null && scrollDistance != 0) {
                new SimpleLaterInvocator() {
                    @Override
                    public void execute() {
                        JViewport viewport = scrollPane.getViewport();
                        Point viewPosition = viewport.getViewPosition();
                        viewport.setViewPosition(new Point((int) (viewPosition.x + scrollDistance), viewPosition.y));
                        calculateScrollDistance();
                    }
                }.start();
            }
        }
View Full Code Here

                }
            }
            return;
        }
        JScrollPane scrollPane = (JScrollPane) container;
        JViewport viewport = scrollPane.getViewport();
        JComponent view = (JComponent) viewport.getView();
        if (isMarkable(view)) {
            return;
        }
        Component wrappedView = new IconFeedbackPanel(model, view);
        viewport.setView(wrappedView);
        wrapComponentTree(model, view);
    }
View Full Code Here

    private static boolean isScrollPaneWithUnmarkableView(final Component c) {
        if (!(c instanceof JScrollPane)) {
            return false;
        }
        JScrollPane scrollPane = (JScrollPane) c;
        JViewport viewport = scrollPane.getViewport();
        JComponent view = (JComponent) viewport.getView();
        return !isMarkable(view);
    }
View Full Code Here

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

          int newX = (int) (anchorIndex.getElement().getX() * realZoom);
          int newY = (int) (anchorIndex.getElement().getY() * 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

  final void pnlLinksMouseDragged(final java.awt.event.MouseEvent evt) {
    // 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

        component = formView.createComponent();
        assertSame(getModelAttribute(elem),
                ((JTextArea) ((Container) ((Container) component)
                        .getComponent(0)).getComponent(0)).getDocument());
        checkWithoutlModel(31, "textArea", "textarea");
        JViewport viewPort = ((JScrollPane)formView.createComponent()).getViewport();
        assertNotNull(((JTextArea)viewPort.getComponent(0)).getDocument());

        createFormView("select_0");
        component = formView.createComponent();
        assertSame(getModelAttribute(elem), ((JComboBox) component).getModel());
        if (isHarmony()) {
View Full Code Here

                ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
                ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
        editorScrollPane.setPreferredSize(new Dimension(250, 145));
        editorScrollPane.setBorder(new EmptyBorder(new Insets(5, 10, 5, 10)));

        JViewport port = editorScrollPane.getViewport();
        port.getVisibleRect().setLocation(0,0);
        editorScrollPane.setViewport(port);

        // String helpTitle1 = ResourceManager.getString("String_Details_Title_1");
        // PanelLabel label1 = new PanelLabel(helpTitle1, true);
        // String helpTitle2 = ResourceManager.getString("String_Details_Title_2");
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.