本文整理了Java中javax.swing.AbstractButton.contains()
方法的一些代码示例,展示了AbstractButton.contains()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AbstractButton.contains()
方法的具体详情如下:
包路径:javax.swing.AbstractButton
类名称: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();
}
}
内容来源于网络,如有侵权,请联系作者删除!