JTextComponent ed = org.netbeans.editor.getMostActiveComponent();

Source: NetBeans FAQ