Point vp = vport.getViewPosition(); vp.translate(pp.x-cp.x, pp.y-cp.y); image.scrollRectToVisible(new Rectangle(vp, vport.getSize())); pp.setLocation(cp);
System.out.println("Y (pos2) : " + startIndex.y); textArea.setCaretPosition(textArea.viewToModel(new Point(startIndex.x, y))); pane.scrollRectToVisible(new Rectangle(startIndex.x, y));
if (focused != null && SwingUtilities.isDescendingFrom(focused, parent)) { parent.scrollRectToVisible(focused.getBounds());
int height = (int)panel.getPreferredSize().getHeight(); Rectangle rect = new Rectangle(0,height,10,10); panel.scrollRectToVisible(rect);
Rectangle visibleRect = component.getVisibleRect(); visibleRect.y = component.getHeight() - visibleRect.height; component.scrollRectToVisible(visibleRect);
@Override public void run () { component.scrollRectToVisible(vr); } });
public void exportTab(int dragIndex, JTabbedPane target, int targetIndex) { Component cmp = this.getComponentAt(dragIndex); Component tab = this.getTabComponentAt(dragIndex); String title = this.getTitleAt(dragIndex); Icon icon = this.getIconAt(dragIndex); String tip = this.getToolTipTextAt(dragIndex); boolean isEnabled = this.isEnabledAt(dragIndex); this.remove(dragIndex); target.insertTab(title, icon, cmp, tip, targetIndex); target.setEnabledAt(targetIndex, isEnabled); target.setTabComponentAt(targetIndex, tab); target.setSelectedIndex(targetIndex); if (tab instanceof JComponent) { ((JComponent) tab).scrollRectToVisible(tab.getBounds()); } }
public void run() { jc.scrollRectToVisible(rect); } });
@Override public void onTimelinePulse(float durationFraction, float timelinePosition) { int x = (int) (oldRectangle.x + timelinePosition * aDeltaX); int y = (int) (oldRectangle.y + timelinePosition * aDeltaY); theComponent.scrollRectToVisible(new Rectangle(x, y, oldRectangle.width, oldRectangle.height)); syncRectangle(); } });
/** * Overrides parent method to add extend flag for making the control * larger during previews. */ public void scrollRectToVisible(Rectangle aRect, boolean extend) { super.scrollRectToVisible(aRect); if (extend) { extendComponent(aRect); } }
private void scrollTo(Point newPoint) { if (point != null && newPoint != null && rect != null) { int deltaX = point.x - newPoint.x; int deltaY = point.y - newPoint.y; rect.x = rect.x + deltaX; rect.y = rect.y + deltaY; ((JComponent) getView()).scrollRectToVisible(rect); point = newPoint; } }
public static void scrollToBottom(JComponent component) { Rectangle visibleRect = component.getVisibleRect(); visibleRect.y = component.getHeight() - visibleRect.height; component.scrollRectToVisible(visibleRect); }
/** * Scrolls a rectangular region of a {@code JComponent} into view. * * @param robot simulates user input. * @param c the {@code JComponent}. * @param rectangle the rectangular region. */ private static void scrollToVisible(@Nonnull Robot robot, final @Nonnull JComponent c, final @Nonnull Rectangle rectangle) { execute(() -> c.scrollRectToVisible(rectangle)); robot.waitForIdle(); }
public void run() { JComponent bestReadyComponent = _frame.txtColumsFactory.getBestReadyComponent(); if(null != bestReadyComponent) { _frame.txtColumsFactory.getBestReadyComponent().scrollRectToVisible(new Rectangle(0,0,1,1)); } } });
void scroll(final int aDeltaX, final int aDeltaY, final boolean _end) { if (theComponent == null) { return; } final Rectangle rect = theComponent.getVisibleRect(); rect.x += aDeltaX; rect.y += aDeltaY; theComponent.scrollRectToVisible(rect); if (_end) { thePopupMenu.setVisible(false); } }
wrapper1.addContainerListener(new ContainerAdapter() { @Override public void componentAdded(final ContainerEvent e) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { JComponent comp = (JComponent) e.getChild(); Rectangle bounds = new Rectangle(comp.getBounds()); comp.scrollRectToVisible(bounds); } }); } });
private void scroll(int aDeltaX, int aDeltaY) { JComponent component = (JComponent) _scrollPane.getViewport().getView(); Rectangle rect = component.getVisibleRect(); rect.x += xOffset + aDeltaX; rect.y += yOffset + aDeltaY; component.scrollRectToVisible(rect); _popupMenu.setVisible(false); } }
@Override public void valueChanged(ListSelectionEvent e) { int row = table.getSelectedRow(); Integer o = (Integer) table.getValueAt(row, 0); Point p = logUmlMapper.getPoint(o); if (p != null) { Rectangle r = new Rectangle(logUmlMapper.getPoint(o)); umlModel.getContentJComponet().scrollRectToVisible(r); } }
@RunsInCurrentThread private static void scrollToVisibleIfIsTextField(@Nonnull JTextComponent textBox, @Nonnull Rectangle r) { if (!(textBox instanceof JTextField)) { return; } Pair<Point, Container> pointAndParent = pointAndParentForScrolling((JTextField) textBox); Container parent = pointAndParent.second; if (parent == null || parent instanceof CellRendererPane || !(parent instanceof JComponent)) { return; } ((JComponent) parent).scrollRectToVisible(addPointToRectangle(checkNotNull(pointAndParent.first), r)); }
private boolean pan (Widget widget, Point newLocation) { if (scrollPane == null || scene != widget.getScene ()) return false; newLocation = scene.convertSceneToView (widget.convertLocalToScene (newLocation)); SwingUtilities.convertPointToScreen (newLocation, scene.getView ()); JComponent view = scene.getView (); Rectangle rectangle = view.getVisibleRect (); rectangle.x += lastLocation.x - newLocation.x; rectangle.y += lastLocation.y - newLocation.y; view.scrollRectToVisible (rectangle); lastLocation = newLocation; return true; }