javax.swing.JComponent.scrollRectToVisible()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(6.1k)|赞(0)|评价(0)|浏览(246)

本文整理了Java中javax.swing.JComponent.scrollRectToVisible()方法的一些代码示例,展示了JComponent.scrollRectToVisible()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JComponent.scrollRectToVisible()方法的具体详情如下:
包路径:javax.swing.JComponent
类名称:JComponent
方法名:scrollRectToVisible

JComponent.scrollRectToVisible介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

Point vp = vport.getViewPosition();
vp.translate(pp.x-cp.x, pp.y-cp.y);
image.scrollRectToVisible(new Rectangle(vp, vport.getSize()));
pp.setLocation(cp);

代码示例来源:origin: stackoverflow.com

System.out.println("Y (pos2) : " + startIndex.y);
textArea.setCaretPosition(textArea.viewToModel(new Point(startIndex.x, y)));
pane.scrollRectToVisible(new Rectangle(startIndex.x, y));

代码示例来源:origin: stackoverflow.com

if (focused != null
  && SwingUtilities.isDescendingFrom(focused, parent)) {
  parent.scrollRectToVisible(focused.getBounds());

代码示例来源:origin: stackoverflow.com

int height = (int)panel.getPreferredSize().getHeight();
Rectangle rect = new Rectangle(0,height,10,10);
panel.scrollRectToVisible(rect);

代码示例来源:origin: stackoverflow.com

Rectangle visibleRect = component.getVisibleRect();
visibleRect.y = component.getHeight() - visibleRect.height;
component.scrollRectToVisible(visibleRect);

代码示例来源:origin: Audiveris/audiveris

@Override
  public void run ()
  {
    component.scrollRectToVisible(vr);
  }
});

代码示例来源:origin: ron190/jsql-injection

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());
  }
}

代码示例来源:origin: abbot/abbot

public void run() {
    jc.scrollRectToVisible(rect);
  }
});

代码示例来源:origin: net.java.dev.laf-widget/laf-widget

@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();
  }
});

代码示例来源:origin: org.tinyjee.jgraphx/jgraphx

/**
 * 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);
  }
}

代码示例来源:origin: sdedit/sdedit

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;
  }
}

代码示例来源:origin: stackoverflow.com

public static void scrollToBottom(JComponent component) 
{
  Rectangle visibleRect = component.getVisibleRect();
  visibleRect.y = component.getHeight() - visibleRect.height;
  component.scrollRectToVisible(visibleRect);
}

代码示例来源:origin: joel-costigliola/assertj-swing

/**
 * 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();
}

代码示例来源:origin: net.sf.squirrel-sql.plugins/graph

public void run()
  {
   JComponent bestReadyComponent = _frame.txtColumsFactory.getBestReadyComponent();
   if(null != bestReadyComponent)
   {
     _frame.txtColumsFactory.getBestReadyComponent().scrollRectToVisible(new Rectangle(0,0,1,1));
   }
  }
});

代码示例来源:origin: org.fudaa.framework.ctulu/ctulu-ui

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);
 }
}

代码示例来源:origin: stackoverflow.com

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);
      }
    });

  }
});

代码示例来源:origin: com.jidesoft/jide-oss

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);
  }
}

代码示例来源:origin: otros-systems/otroslogviewer

@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);
 }
}

代码示例来源:origin: joel-costigliola/assertj-swing

@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));
}

代码示例来源:origin: org.netbeans.api/org-netbeans-api-visual

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;
}

相关文章

JComponent类方法