本文整理匯總了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());
}
}
示例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();
}