views:

230

answers:

1

Hello,

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)

+1  A: 

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.

CarlG
It is nicd you found it. But I used another lib, a mutch better.`jsyntaxpane-0.9.5-b27.jar` is the name.
Martijn Courteaux