javax.swing.plaf.basic.BasicButtonListener.focusGained()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(1.6k)|赞(0)|评价(0)|浏览(82)

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

BasicButtonListener.focusGained介绍

暂无

代码示例

代码示例来源: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();
  }
}

相关文章