Java Code Examples for javax.swing.JEditorPane#requestFocusInWindow()
The following examples show how to use
javax.swing.JEditorPane#requestFocusInWindow() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CssExternalDropHandler.java From netbeans with Apache License 2.0 | 6 votes |
@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()); } }
Example 2
Source File: MethodChooser.java From netbeans with Apache License 2.0 | 6 votes |
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(); }
Example 3
Source File: HtmlExternalDropHandler.java From netbeans with Apache License 2.0 | 6 votes |
@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()); } }
Example 4
Source File: CakePHPExternalDropHandler.java From cakephp3-netbeans with Apache License 2.0 | 6 votes |
@Override public boolean canDrop(DropTargetDragEvent event) { JEditorPane editorPane = findPane(event.getDropTargetContext().getComponent()); if (editorPane == null || !isInCakePHP(editorPane)) { return false; } Transferable t = event.getTransferable(); canDrop = canDrop(t); if (!canDrop) { return false; } editorPane.setCaretPosition(getOffset(editorPane, event.getLocation())); editorPane.requestFocusInWindow(); //pity we need to call this all the time when dragging, but ExternalDropHandler don't handle dragEnter event return canDrop(event.getCurrentDataFlavors()); }