本文整理汇总了Java中javax.swing.SwingUtilities.getDeepestComponentAt方法的典型用法代码示例。如果您正苦于以下问题:Java SwingUtilities.getDeepestComponentAt方法的具体用法?Java SwingUtilities.getDeepestComponentAt怎么用?Java SwingUtilities.getDeepestComponentAt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.SwingUtilities
的用法示例。
在下文中一共展示了SwingUtilities.getDeepestComponentAt方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: eventDispatched
import javax.swing.SwingUtilities; //导入方法依赖的package包/类
@Override public void eventDispatched(AWTEvent event) {
if (ignoreMouseEvents) {
return;
}
Component root = SwingUtilities.getRoot((Component) event.getSource());
if (root instanceof IRecordingArtifact || root.getName().startsWith("###")) {
return;
}
if (!(event instanceof MouseEvent)) {
return;
}
MouseEvent mouseEvent = (MouseEvent) event;
mouseEvent.consume();
if (event.getID() == MouseEvent.MOUSE_PRESSED) {
disposeOverlay();
Component mouseComponent = SwingUtilities.getDeepestComponentAt(mouseEvent.getComponent(), mouseEvent.getX(),
mouseEvent.getY());
if (mouseComponent == null) {
return;
}
mouseEvent = SwingUtilities.convertMouseEvent(mouseEvent.getComponent(), mouseEvent, mouseComponent);
setComponent(mouseComponent, mouseEvent.getPoint(), true);
return;
}
}
示例2: updateClientCursor
import javax.swing.SwingUtilities; //导入方法依赖的package包/类
private void updateClientCursor() {
PointerInfo pointerInfo = MouseInfo.getPointerInfo();
if (pointerInfo == null) {
/*
* This can happen when multiple graphics device cannot decide
* which graphics device contains the current mouse position
* or on systems without a mouse
*/
return;
}
Point p = pointerInfo.getLocation();
SwingUtilities.convertPointFromScreen(p, this);
Component target = SwingUtilities.getDeepestComponentAt(this, p.x, p.y);
if (target != null) {
content.setCursor(target.getCursor());
}
}
示例3: getToolTipText
import javax.swing.SwingUtilities; //导入方法依赖的package包/类
@Override
public String getToolTipText(MouseEvent event) {
Component c = SwingUtilities.getDeepestComponentAt(this, event.getX(), event.getY());
if (c instanceof JComponent) {
JComponent jc = (JComponent) c;
String tooltip = jc.getToolTipText();
if (null != tooltip) {
return tooltip;
}
}
return super.getToolTipText(event);
}
示例4: getDeepestComponent
import javax.swing.SwingUtilities; //导入方法依赖的package包/类
private Component getDeepestComponent(MouseEvent e) {
Point contentPanePoint
= SwingUtilities.convertPoint(glassPane,
e.getPoint(),
contentPane);
return SwingUtilities.getDeepestComponentAt(
contentPane,
contentPanePoint.x,
contentPanePoint.y);
}
示例5: getActiveComponent
import javax.swing.SwingUtilities; //导入方法依赖的package包/类
public static Component getActiveComponent(Component component, int x, int y) {
Component componentx = SwingUtilities.getDeepestComponentAt(component, x, y);
if (componentx == null) {
return component;
}
return componentx;
}
示例6: showPopup
import javax.swing.SwingUtilities; //导入方法依赖的package包/类
public void showPopup(MouseEvent mouseEvent) {
if (isContextMenuOn()) {
return;
}
Component component = SwingUtilities.getDeepestComponentAt(mouseEvent.getComponent(), mouseEvent.getX(), mouseEvent.getY());
if (component == null) {
return;
}
if (component instanceof JMenuItem && (!(component instanceof JMenu) || ((JMenu) component).isSelected())) {
return;
}
Point point = SwingUtilities.convertPoint(mouseEvent.getComponent(), mouseEvent.getPoint(), component);
showPopup(component, point);
}
示例7: shouldSelectCell
import javax.swing.SwingUtilities; //导入方法依赖的package包/类
public boolean shouldSelectCell(EventObject anEvent) {
if( editorComponent != null && anEvent instanceof MouseEvent
&& ((MouseEvent)anEvent).getID() == MouseEvent.MOUSE_PRESSED )
{
Component dispatchComponent = SwingUtilities.getDeepestComponentAt(editorComponent, 3, 3 );
((CopyButton) dispatchComponent).setSelected(true);
}
return false;
}
示例8: updateClientCursor
import javax.swing.SwingUtilities; //导入方法依赖的package包/类
private void updateClientCursor() {
Point p = MouseInfo.getPointerInfo().getLocation();
SwingUtilities.convertPointFromScreen(p, this);
Component target = SwingUtilities.getDeepestComponentAt(this, p.x, p.y);
if (target != null) {
content.setCursor(target.getCursor());
}
}
示例9: redispatchComponent
import javax.swing.SwingUtilities; //导入方法依赖的package包/类
private boolean redispatchComponent(MouseEvent e) {
Point p = e.getPoint();
int index = list.locationToIndex(p);
if (index < 0 || index >= list.getModel().getSize()) {
return false;
}
ListCellRenderer renderer = list.getCellRenderer();
if (null == renderer) {
return false;
}
Component renComponent = renderer.getListCellRendererComponent(list, list.getModel().getElementAt(index), index, false, false);
if (null == renComponent) {
return false;
}
Rectangle rect = list.getCellBounds(index, index);
if (null == rect) {
return false;
}
renComponent.setBounds(0, 0, rect.width, rect.height);
renComponent.doLayout();
Point p3 = rect.getLocation();
Point p2 = new Point(p.x - p3.x, p.y - p3.y);
Component dispatchComponent =
SwingUtilities.getDeepestComponentAt(renComponent,
p2.x, p2.y);
if ( e.isPopupTrigger() &&
dispatchComponent instanceof LinkButton &&
!((LinkButton)dispatchComponent).isHandlingPopupEvents() )
{
return false;
}
if (dispatchComponent instanceof AbstractButton) {
if (!((AbstractButton) dispatchComponent).isEnabled()) {
return false;
}
Point p4 = SwingUtilities.convertPoint(renComponent, p2, dispatchComponent);
MouseEvent newEvent = new MouseEvent(dispatchComponent,
e.getID(),
e.getWhen(),
e.getModifiers(),
p4.x, p4.y,
e.getClickCount(),
e.isPopupTrigger(),
MouseEvent.NOBUTTON);
dispatchComponent.dispatchEvent(newEvent);
list.repaint(rect);
e.consume();
return true;
}
return false;
}
示例10: setDispatchComponent
import javax.swing.SwingUtilities; //导入方法依赖的package包/类
private void setDispatchComponent(MouseEvent e) {
Component editorComponent = header.getEditorComponent();
Point p = e.getPoint();
Point p2 = SwingUtilities.convertPoint(header, p, editorComponent);
dispatchComponent = SwingUtilities.getDeepestComponentAt(editorComponent, p2.x, p2.y);
}