Example usage for com.intellij.openapi.wm IdeFocusManager getFocusTargetFor

List of usage examples for com.intellij.openapi.wm IdeFocusManager getFocusTargetFor

Introduction

In this page you can find the example usage for com.intellij.openapi.wm IdeFocusManager getFocusTargetFor.

Prototype

@Nullable
public abstract JComponent getFocusTargetFor(@NotNull JComponent comp);

Source Link

Document

Finds most suitable component to request focus to.

Usage

From source file:com.intellij.help.impl.IdeaHelpBroker.java

License:Apache License

/**
 * Displays the presentation to the user.
 *///ww  w  . java 2  s  .co m
public void setDisplayed(boolean visible) {
    createHelpWindow();
    if (myModallyActivated) {
        myDialog.setVisible(visible);
        if (visible) {
            myDialog.setLocationRelativeTo(myDialog.getOwner());
        }
    } else {
        //myFrame.setLocationRelativeTo(null);
        myFrame.setVisible(visible);
        myFrame.setState(JFrame.NORMAL);
        IdeFocusManager focusManager = IdeFocusManager.findInstance();
        JComponent target = focusManager.getFocusTargetFor(myFrame.getRootPane());
        focusManager.requestFocus(target != null ? target : myFrame, true);
    }
}