當前位置: 首頁>>代碼示例>>Java>>正文


Java JEditorPane.requestFocusInWindow方法代碼示例

本文整理匯總了Java中javax.swing.JEditorPane.requestFocusInWindow方法的典型用法代碼示例。如果您正苦於以下問題:Java JEditorPane.requestFocusInWindow方法的具體用法?Java JEditorPane.requestFocusInWindow怎麽用?Java JEditorPane.requestFocusInWindow使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.swing.JEditorPane的用法示例。


在下文中一共展示了JEditorPane.requestFocusInWindow方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: canDrop

import javax.swing.JEditorPane; //導入方法依賴的package包/類
@Override
public boolean canDrop(DropTargetDragEvent e) {
    //check if the JEditorPane contains html document
    JEditorPane pane = findPane(e.getDropTargetContext().getComponent());
    if (pane == null) {
        return false;
    }
    int offset = getLineEndOffset(pane, e.getLocation());
    if (!containsLanguageAtOffset(pane.getDocument(), offset)) {
        return false;
    } else {
        //update the caret as the user drags the object
        //needs to be done explicitly here as QuietEditorPane doesn't call
        //the original Swings DropTarget which does this
        pane.setCaretPosition(offset);

        pane.requestFocusInWindow(); //pity we need to call this all the time when dragging, but  ExternalDropHandler don't handle dragEnter event

        return canDrop(e.getCurrentDataFlavors());
    }

}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:23,代碼來源:CssExternalDropHandler.java

示例2: requestFocus

import javax.swing.JEditorPane; //導入方法依賴的package包/類
private static void requestFocus(final JEditorPane editorPane) {
    if (!SwingUtilities.isEventDispatchThread()) {
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                requestFocus(editorPane);
            }
        });
        return ;
    }
    Container p = editorPane;
    while ((p = p.getParent()) != null) {
        if (p instanceof TopComponent) {
            ((TopComponent) p).requestActive();
            break;
        }
    }
    editorPane.requestFocusInWindow();
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:20,代碼來源:MethodChooser.java


注:本文中的javax.swing.JEditorPane.requestFocusInWindow方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。