javax.swing.JWindow.getLocation()方法的使用及代码示例

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

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

JWindow.getLocation介绍

暂无

代码示例

代码示例来源:origin: Baralga/baralga

@Override
  public void mouseDragged(MouseEvent e) {
    // get location of Window
    int thisX = parent.getLocation().x;
    int thisY = parent.getLocation().y;
    // Determine how much the mouse moved since the initial click
    int xMoved = (thisX + e.getX()) - (thisX + initialClick.x);
    int yMoved = (thisY + e.getY()) - (thisY + initialClick.y);
    // Move window to this position
    int X = thisX + xMoved;
    int Y = thisY + yMoved;
    parent.setLocation(X, Y);
  }
});

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

public void moveVertical(int offset) {
  Point location = window.getLocation();
  location.y += offset;
  window.setLocation(location);
}

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

timer.scheduleAtFixedRate(new TimerTask() {
  public void run() {
    jWindow.setLocation(jWindow.getLocation().x + 25, jWindow.getLocation().y + 24);
    if (jWindow.getLocation().x > Toolkit.getDefaultToolkit().getScreenSize().width / 2) {
      jWindow.setLocation(0, 0);
    if (jWindow.getLocation().y > Toolkit.getDefaultToolkit().getScreenSize().height / 2) {
      jWindow.setLocation(0, 0);

代码示例来源:origin: undera/jmeter-plugins

private synchronized void showHoverInfo() {
  if (isPreview
      || chartRect.width == 0 || chartRect.height == 0
      || xHoverInfo == -1 || yHoverInfo == -1) {
    return;
  }
  long realX = minXVal + (maxXVal - minXVal) * (xHoverInfo - chartRect.x) / chartRect.width;
  double realY = minYVal + (maxYVal - minYVal) * (chartRect.height - yHoverInfo + chartRect.y) / chartRect.height;
  xAxisLabelRenderer.setValue(realX);
  yAxisLabelRenderer.setValue(realY);
  String hoverInfo = "(" + xAxisLabelRenderer.getText() + " ; " + yAxisLabelRenderer.getText() + ")";
  hoverLabel.setText(hoverInfo);
  int labelWidth = hoverLabel.getPreferredSize().width + 5;
  int labelHeight = hoverLabel.getPreferredSize().height;
  if (hoverWindow.getWidth() < labelWidth || hoverWindow.getHeight() < labelHeight) {
    hoverWindow.setSize(labelWidth, labelHeight);
  }
  Point mousePos = MouseInfo.getPointerInfo().getLocation();
  int hoverWindowX = mousePos.x + hoverGap;
  int hoverWindowY = mousePos.y + hoverGap;
  //we move window only if far from pointer to limit cpu
  double deltaX = Math.abs(hoverWindow.getLocation().getX() - hoverWindowX);
  double deltaY = Math.abs(hoverWindow.getLocation().getY() - hoverWindowY);
  if (forceHoverPosition || deltaX >= hoverGap || deltaY >= hoverGap) {
    //prevent out of screen
    int correctedX = Math.min(hoverWindowX, Toolkit.getDefaultToolkit().getScreenSize().width - hoverWindow.getSize().width);
    hoverWindow.setLocation(correctedX, hoverWindowY);
    forceHoverPosition = false;
  }
}

代码示例来源:origin: kg.apc/jmeter-plugins-cmn-jmeter

private synchronized void showHoverInfo() {
  if (isPreview
      || chartRect.width == 0 || chartRect.height == 0
      || xHoverInfo == -1 || yHoverInfo == -1) {
    return;
  }
  long realX = minXVal + (maxXVal - minXVal) * (xHoverInfo - chartRect.x) / chartRect.width;
  double realY = minYVal + (maxYVal - minYVal) * (chartRect.height - yHoverInfo + chartRect.y) / chartRect.height;
  xAxisLabelRenderer.setValue(realX);
  yAxisLabelRenderer.setValue(realY);
  String hoverInfo = "(" + xAxisLabelRenderer.getText() + " ; " + yAxisLabelRenderer.getText() + ")";
  hoverLabel.setText(hoverInfo);
  int labelWidth = hoverLabel.getPreferredSize().width + 5;
  int labelHeight = hoverLabel.getPreferredSize().height;
  if (hoverWindow.getWidth() < labelWidth || hoverWindow.getHeight() < labelHeight) {
    hoverWindow.setSize(labelWidth, labelHeight);
  }
  Point mousePos = MouseInfo.getPointerInfo().getLocation();
  int hoverWindowX = mousePos.x + hoverGap;
  int hoverWindowY = mousePos.y + hoverGap;
  //we move window only if far from pointer to limit cpu
  double deltaX = Math.abs(hoverWindow.getLocation().getX() - hoverWindowX);
  double deltaY = Math.abs(hoverWindow.getLocation().getY() - hoverWindowY);
  if (forceHoverPosition || deltaX >= hoverGap || deltaY >= hoverGap) {
    //prevent out of screen
    int correctedX = Math.min(hoverWindowX, Toolkit.getDefaultToolkit().getScreenSize().width - hoverWindow.getSize().width);
    hoverWindow.setLocation(correctedX, hoverWindowY);
    forceHoverPosition = false;
  }
}

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

int result = this.isVisible ? this.currTabIndex : -1;
final Point currWindowLocation = this.currTabWindow.getLocation();
final Dimension currWindowSize = this.currTabWindow.getSize();
final Point nextWindowLocation = this.nextTabWindow.getLocation();
final Dimension nextWindowSize = this.nextTabWindow.getSize();
final Point prevWindowLocation = this.prevTabWindow.getLocation();
final Dimension prevWindowSize = this.prevTabWindow.getSize();

相关文章