javax.swing.AbstractButton.contains()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(2.7k)|赞(0)|评价(0)|浏览(176)

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

AbstractButton.contains介绍

暂无

代码示例

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

@Override
public void mouseReleased(MouseEvent e) {
  AbstractButton b = (AbstractButton) e.getSource();
  ButtonModel model = b.getModel();
  if (b.contains(e.getPoint())) {
    if (b.isRolloverEnabled()) {
      model.setRollover(true);
    }
  }
  if (!_mouseOver) {
    // these two lines order matters. In this order, it would not trigger actionPerformed.
    model.setArmed(false);
    model.setPressed(false);
  }
  super.mouseReleased(e);
  cancelMenuIfNecessary(e);
}

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

@Override
public void mousePressed(MouseEvent e) {
  if (SwingUtilities.isLeftMouseButton(e)) {
    AbstractButton b = (AbstractButton) e.getSource();
    if (b.contains(e.getX(), e.getY())) {
      long multiClickThreshold = b.getMultiClickThreshhold();
      long lastTime = lastPressedTimestamp;
      long currentTime = lastPressedTimestamp = e.getWhen();
      if (lastTime != -1 && currentTime - lastTime < multiClickThreshold) {
        shouldDiscardRelease = true;
        return;
      }
      ButtonModel model = b.getModel();
      if (!model.isEnabled()) {
        // Disabled buttons ignore all input...
        return;
      }
      if (!model.isArmed()) {
        // button not armed, should be
        model.setArmed(true);
      }
      model.setPressed(true);
      if (!b.hasFocus() && b.isRequestFocusEnabled()) {
        b.requestFocus();
      }
    }
  }
}

代码示例来源:origin: org.java.net.substance/substance

@Override
public void focusGained(FocusEvent e) {
  this.stateTransitionTracker.turnOffModelChangeTracking();
  try {
    super.focusGained(e);
    if (!this.button.isShowing()) {
      // shouldn't happen. Is some lurking Swing bug
      return;
    }
    try {
      PointerInfo pi = MouseInfo.getPointerInfo();
      int px = pi.getLocation().x
          - this.button.getLocationOnScreen().x;
      int py = pi.getLocation().y
          - this.button.getLocationOnScreen().y;
      this.button.getModel()
          .setRollover(this.button.contains(px, py));
    } catch (AccessControlException ace) {
      // sandbox - give up
    }
  } finally {
    this.stateTransitionTracker.onModelStateChanged();
  }
}

代码示例来源:origin: com.github.insubstantial/substance

@Override
public void focusGained(FocusEvent e) {
  this.stateTransitionTracker.turnOffModelChangeTracking();
  try {
    super.focusGained(e);
    if (!this.button.isShowing()) {
      // shouldn't happen. Is some lurking Swing bug
      return;
    }
    try {
      PointerInfo pi = MouseInfo.getPointerInfo();
      if (pi == null) return;  //pointer not on a graphics device
      int px = pi.getLocation().x
          - this.button.getLocationOnScreen().x;
      int py = pi.getLocation().y
          - this.button.getLocationOnScreen().y;
      this.button.getModel()
          .setRollover(this.button.contains(px, py));
    } catch (AccessControlException ace) {
      // sandbox - give up
    }
  } finally {
    this.stateTransitionTracker.onModelStateChanged();
  }
}

相关文章

微信公众号

最新文章

更多

AbstractButton类方法