Reputation: 68897
I just met the lib BeanShell. And now I'm making a Java Editor with a run-button who runs the code without compiling. For the texteditor-component, I use the open-source jEdit Syntax Package. Here is a link with a demo: link.
Now I wrote code that adds every time the user pressed enter automaticly added the same number of tabs like the previous line starts with. I tested that code in a simple JTextArea
and works correctly. But it seems the keyevents are not working with the JEditTextArea
I put this JComponent in a JPanel
.
The JEditTextArea
is the editor-component in the lib. (Extends JComponent
)
Upvotes: 0
Views: 861
Reputation: 1666
The JEditTextArea
doesn't behave like a normal swing JTextComponent
. See the overridden processKeyEvent
code in JEditTextArea - it specifically avoids the KeyListener stuff for performance.
The way I've added key handling logic to JEditTextArea is to subclass the DefaultInputHandler
and override addDefaultKeyBindings
, calling addKeyBinding()
with your desired bindings and logic.
Upvotes: 1