本文整理汇总了Java中org.netbeans.editor.Utilities.getFocusedComponent方法的典型用法代码示例。如果您正苦于以下问题:Java Utilities.getFocusedComponent方法的具体用法?Java Utilities.getFocusedComponent怎么用?Java Utilities.getFocusedComponent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.netbeans.editor.Utilities
的用法示例。
在下文中一共展示了Utilities.getFocusedComponent方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setMenu
import org.netbeans.editor.Utilities; //导入方法依赖的package包/类
/** Sets the state of JMenuItem*/
protected @Override void setMenu(){
ActionMap am = getContextActionMap();
Action action = null;
if (am != null) {
action = am.get(getActionName());
}
JMenuItem presenter = getMenuPresenter();
Action presenterAction = presenter.getAction();
if (presenterAction == null){
presenter.setAction(this);
presenter.setToolTipText(null); /* bugfix #62872 */
menuInitialized = false;
}
else {
if (!this.equals(presenterAction)){
presenter.setAction(this);
presenter.setToolTipText(null); /* bugfix #62872 */
menuInitialized = false;
}
}
if (!menuInitialized){
Mnemonics.setLocalizedText(presenter, getMenuItemText());
menuInitialized = true;
}
presenter.setEnabled(action != null);
JTextComponent comp = Utilities.getFocusedComponent();
if (comp != null && comp instanceof JEditorPane){
addAccelerators(this, presenter, comp);
} else {
presenter.setAccelerator(getDefaultAccelerator());
}
}
示例2: actionPerformed
import org.netbeans.editor.Utilities; //导入方法依赖的package包/类
public void actionPerformed(ActionEvent e) {
ActiveEditorDrop drop = (ActiveEditorDrop) item.lookup(ActiveEditorDrop.class);
JTextComponent target = Utilities.getFocusedComponent();
if (target == null) {
String msg = NbBundle.getMessage(HtmlPaletteActions.class, "MSG_ErrorNoFocusedDocument"); //NOI18N
DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(msg, NotifyDescriptor.ERROR_MESSAGE));
return;
}
try {
drop.handleTransfer(target);
}
finally {
Utilities.requestFocus(target);
}
try {
FileObject fo = DataLoadersBridge.getDefault().getFileObject(target);
if(fo != null) {
PaletteController pc = HtmlPaletteFactory.getPalette(fo.getMIMEType());
pc.clearSelection();
}
}
catch (IOException ignored) {
}
}
示例3: getComponent
import org.netbeans.editor.Utilities; //导入方法依赖的package包/类
private static JTextComponent getComponent(){
return Utilities.getFocusedComponent();
}
示例4: getComponent
import org.netbeans.editor.Utilities; //导入方法依赖的package包/类
/** Returns focused editor component */
private static JTextComponent getComponent(){
return Utilities.getFocusedComponent();
}