当前位置: 首页>>代码示例>>Java>>正文


Java SwingUtilities.isDescendingFrom方法代码示例

本文整理汇总了Java中javax.swing.SwingUtilities.isDescendingFrom方法的典型用法代码示例。如果您正苦于以下问题:Java SwingUtilities.isDescendingFrom方法的具体用法?Java SwingUtilities.isDescendingFrom怎么用?Java SwingUtilities.isDescendingFrom使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.SwingUtilities的用法示例。


在下文中一共展示了SwingUtilities.isDescendingFrom方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: executeCommand

import javax.swing.SwingUtilities; //导入方法依赖的package包/类
public void executeCommand() {
  PrivateChatter chat = mgr.getChatterFor(p);
  if (chat == null) {
    return;
  }

  Window f = SwingUtilities.getWindowAncestor(chat);
  if (!f.isVisible()) {
    f.setVisible(true);
    Component c = KeyboardFocusManager.getCurrentKeyboardFocusManager()
                                      .getFocusOwner();
    if (c == null || !SwingUtilities.isDescendingFrom(c, f)) {
      java.awt.Toolkit.getDefaultToolkit().beep();
      for (int i = 0,j = chat.getComponentCount(); i < j; ++i) {
        if (chat.getComponent(i) instanceof JTextField) {
          (chat.getComponent(i)).requestFocus();
          break;
        }
      }
    }
  }
  else {
    f.toFront();
  }
  chat.show(msg);
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:27,代码来源:PrivMsgCommand.java

示例2: requestFocusInWindow

import javax.swing.SwingUtilities; //导入方法依赖的package包/类
/** Transfer the focus to the editor pane.
 */
@Deprecated
@Override
public boolean requestFocusInWindow() {
    super.requestFocusInWindow();

    if (pane != null) {
        if ((customComponent != null) && !SwingUtilities.isDescendingFrom(pane, customComponent)) {
            return customComponent.requestFocusInWindow();
        } else {
            return pane.requestFocusInWindow();
        }
    }

    return false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:CloneableEditor.java

示例3: eventDispatched

import javax.swing.SwingUtilities; //导入方法依赖的package包/类
@Override
public void eventDispatched(AWTEvent e) {
	if (e instanceof MouseEvent) {
		MouseEvent me = (MouseEvent) e;
		if (!SwingUtilities.isDescendingFrom(me.getComponent(), target)) {
			return;
		}
		if (me.getID() == MouseEvent.MOUSE_RELEASED) {
			// stop when mouse released
			mouseOnScreenPoint = null;
			if (timer.isRunning()) {
				timer.stop();
			}
		} else if (me.getID() == MouseEvent.MOUSE_DRAGGED && me.getComponent() == target) {
			mouseOnScreenPoint = me.getLocationOnScreen();
		} else if (me.getID() == MouseEvent.MOUSE_PRESSED && me.getComponent() == target) {
			mouseOnScreenPoint = me.getLocationOnScreen();
			timer.start();
		}
	}
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:22,代码来源:PanningManager.java

示例4: isFocusInside

import javax.swing.SwingUtilities; //导入方法依赖的package包/类
/**
 * Checks if the focus is still on this component or its child components.
 */
private boolean isFocusInside(Object newFocusedComp) {
	if (newFocusedComp instanceof Popup) {
		return true;
	}
	if (newFocusedComp instanceof Component && !SwingUtilities.isDescendingFrom((Component) newFocusedComp, this)) {
		// Check if focus is on other window
		if (containingWindow == null) {
			return false;
		}

		Window focusedWindow = KeyboardFocusManager.getCurrentKeyboardFocusManager().getActiveWindow();

		// if focus is on other window return true
		if (containingWindow == focusedWindow) {
			return false;
		}
	}
	return true;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:23,代码来源:PopupPanel.java

示例5: focusSpinnerIfNecessary

import javax.swing.SwingUtilities; //导入方法依赖的package包/类
/**
 * Requests focus on a child of the spinner if the spinner doesn't have
 * focus.
 */
private void focusSpinnerIfNecessary()
{
	Component fo = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
	if( spinner.isRequestFocusEnabled() && (fo == null || !SwingUtilities.isDescendingFrom(fo, spinner)) )
	{
		Container root = spinner;

		if( !root.isFocusCycleRoot() )
		{
			root = root.getFocusCycleRootAncestor();
		}
		if( root != null )
		{
			FocusTraversalPolicy ftp = root.getFocusTraversalPolicy();
			Component child = ftp.getComponentAfter(root, spinner);

			if( child != null && SwingUtilities.isDescendingFrom(child, spinner) )
			{
				child.requestFocus();
			}
		}
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:28,代码来源:FlatterSpinnerUI.java

示例6: isFocused

import javax.swing.SwingUtilities; //导入方法依赖的package包/类
public boolean isFocused() {
    ResultViewPanel rvp = getCurrentResultViewPanel();
    if (rvp != null) {
        Component owner = FocusManager.getCurrentManager().getFocusOwner();
        return owner != null && SwingUtilities.isDescendingFrom(owner, rvp);
    } else {
        return false;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:ResultView.java

示例7: addDirtyRegion

import javax.swing.SwingUtilities; //导入方法依赖的package包/类
@Override
public void addDirtyRegion(JComponent c, int x, int y, int w, int h) {
    for (JComponent dc : logComponents) {
        if (SwingUtilities.isDescendingFrom(dc, c)) {
            String boundsMsg = ViewUtils.toString(new Rectangle(x, y, w, h));
            ViewHierarchyImpl.REPAINT_LOG.log(Level.FINER,
                    "Component-REPAINT: " + boundsMsg + // NOI18N
                    " c:" + ViewUtils.toString(c), // NOI18N
                    new Exception("Component-Repaint of " + boundsMsg + " cause:")); // NOI18N
            break;
        }
    }

    super.addDirtyRegion(c, x, y, w, h);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:DebugRepaintManager.java

示例8: notifyActiveTopComponentChanged

import javax.swing.SwingUtilities; //导入方法依赖的package包/类
public void notifyActiveTopComponentChanged(Component activeTopComponent) {
    if (activeTopComponent != null) {
        JTextComponent activeTextComponent = activeTextComponentRef.get();
        if (activeTextComponent != null) {
            if (!SwingUtilities.isDescendingFrom(activeTextComponent, activeTopComponent)) {
                // A top component was focused that does not contain focused text component
                // so notify that there's in fact no active text component
                if (LOG.isLoggable(Level.FINE)) {
                    LOG.fine("EditorRegistryWatcher: TopComponent without active JTextComponent\n");
                }
                updateActiveActionInPresenters(null);
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:EditorRegistryWatcher.java

示例9: requestFocus

import javax.swing.SwingUtilities; //导入方法依赖的package包/类
/** Transfer the focus to the editor pane.
 */
@Deprecated
@Override
public void requestFocus() {
    super.requestFocus();

    if (pane != null) {
        if ((customComponent != null) && !SwingUtilities.isDescendingFrom(pane, customComponent)) {
            customComponent.requestFocus();
        } else {
            pane.requestFocus();
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:CloneableEditor.java

示例10: requestDefaultFocus

import javax.swing.SwingUtilities; //导入方法依赖的package包/类
@Deprecated
@Override
public boolean requestDefaultFocus() {
    if ((customComponent != null) && !SwingUtilities.isDescendingFrom(pane, customComponent)) {
        return customComponent.requestFocusInWindow();
    } else if (pane != null) {
        return pane.requestFocusInWindow();
    }

    return false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:CloneableEditor.java

示例11: switchCurrentEditor

import javax.swing.SwingUtilities; //导入方法依赖的package包/类
private boolean switchCurrentEditor() {
    final TopComponent tc = TopComponent.getRegistry().getActivated();
    if( null == tc || !TopComponentTracker.getDefault().isEditorTopComponent( tc ) )
        return false;

    final WindowManagerImpl wmi = WindowManagerImpl.getInstance();
    final JFrame mainWnd = ( JFrame ) wmi.getMainWindow();
    if( SwingUtilities.isDescendingFrom( tc, mainWnd.getContentPane() ) )
        return true;
    JPanel panel = new JPanel( new BorderLayout() );
    panel.add( tc, BorderLayout.CENTER  );
    try {
        mainWnd.setContentPane( panel );
    } catch( IndexOutOfBoundsException e ) {
        Logger.getLogger(EditorOnlyDisplayer.class.getName()).log(Level.INFO, "Error while switching current editor.", e);
        //#245541 - something is broken in the component hierarchy, let's try restoring to the default mode
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                cancel(false);
            }
        });
    }
    mainWnd.invalidate();
    mainWnd.revalidate();
    mainWnd.repaint();
    SwingUtilities.invokeLater( new Runnable() {
        @Override
        public void run() {
            tc.requestFocusInWindow();
        }
    });
    return true;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:35,代码来源:EditorOnlyDisplayer.java

示例12: actionPerformed

import javax.swing.SwingUtilities; //导入方法依赖的package包/类
public void actionPerformed (ActionEvent evt) {
    Component focusOwner = FocusManager.getCurrentManager().getFocusOwner();
    // move focus away only from navigator AWT children,
    // but not combo box to preserve its ESC functionality
    if (lastActivatedRef == null ||
        focusOwner == null ||
        !SwingUtilities.isDescendingFrom(focusOwner, navigatorTC.getTopComponent()) ||
        focusOwner instanceof JComboBox) {
        return;
    }
    TopComponent prevFocusedTc = lastActivatedRef.get();
    if (prevFocusedTc != null) {
        prevFocusedTc.requestActive();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:NavigatorController.java

示例13: refreshStatusLine

import javax.swing.SwingUtilities; //导入方法依赖的package包/类
static void refreshStatusLine() {
    LOG.fine("StatusLineFactories.refreshStatusLine()\n");
    List<? extends JTextComponent> componentList = EditorRegistry.componentList();
    for (JTextComponent component : componentList) {
        boolean underMainWindow = (SwingUtilities.isDescendingFrom(component,
                WindowManager.getDefault().getMainWindow()));
        EditorUI editorUI = Utilities.getEditorUI(component);
        if (LOG.isLoggable(Level.FINE)) {
            String componentDesc = component.toString();
            Document doc = component.getDocument();
            Object streamDesc;
            if (doc != null && ((streamDesc = doc.getProperty(Document.StreamDescriptionProperty)) != null)) {
                componentDesc = streamDesc.toString();
            }
            LOG.fine("  underMainWindow=" + underMainWindow + // NOI18N
                    ", text-component: " + componentDesc + "\n");
        }
        if (editorUI != null) {
            StatusBar statusBar = editorUI.getStatusBar();
            statusBar.setVisible(!underMainWindow);
            boolean shouldUpdateGlobal = underMainWindow && component.isShowing();
            if (shouldUpdateGlobal) {
                statusBar.updateGlobal();
                LOG.fine("  end of refreshStatusLine() - found main window component\n\n"); // NOI18N
                return; // First non-docked one found and updated -> quit
            }
        }
    }
    clearStatusLine();
    LOG.fine("  end of refreshStatusLine() - no components - status line cleared\n\n"); // NOI18N
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:32,代码来源:StatusLineFactories.java

示例14: addNotify

import javax.swing.SwingUtilities; //导入方法依赖的package包/类
/** Overrides superclass method to set default button. */
@Override
public void addNotify() {
    super.addNotify();
    
    if (withButtons) {
        if (SwingUtilities.isDescendingFrom(replaceButton, this)) {
            getRootPane().setDefaultButton(replaceButton);
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:I18nPanel.java

示例15: eventDispatched

import javax.swing.SwingUtilities; //导入方法依赖的package包/类
public void eventDispatched(AWTEvent event) {
    if (event instanceof MouseEvent) {
        MouseEvent me = (MouseEvent) event;
        Component mecmp = me.getComponent();

        if (!SwingUtilities.isDescendingFrom(mecmp, (Component) rootPaneContainer)) {
            return;
        }
        if ((me.getID() == MouseEvent.MOUSE_EXITED) && (mecmp == rootPaneContainer)) {
            highcmp = null;
            point = null;
        } else {
            MouseEvent converted = SwingUtilities.convertMouseEvent(mecmp, me, this);
            point = converted.getPoint();
            Component parent = mecmp;
            Rectangle rect = new Rectangle();
            rect.width = mecmp.getWidth();
            rect.height = mecmp.getHeight();
            Rectangle parentBounds = new Rectangle();
            while ((parent != null) && (parent != this.getRootPane()) && (parent != rootPaneContainer)) {
                parent.getBounds(parentBounds);
                rect.x += parentBounds.x;
                rect.y += parentBounds.y;
                parent = parent.getParent();
            }
            highcmp = rect;
        }
        repaint();
    }
}
 
开发者ID:igr,项目名称:swingspy,代码行数:31,代码来源:SwingSpyGlassPane.java


注:本文中的javax.swing.SwingUtilities.isDescendingFrom方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。