In-place text edit problem


I use JGoTextNode to allow use to enter text comment in the JGO. When use click or double click the JGoTextNode, in-place text editing will happen.
The problem of edit is when use enter multiple line, user can not see what he/she is typing. The editor does not scroll so that it allow user. Based on the user’s guide, jView use JGoTextEdit to edit text.
How can I adding scroll function when user enter multiple lines in the editor?


A JGoText object, when starting editing, creates a JGoTextEdit object with the desired bounding rectangle. This is done in JGoText.doStartEdit.
The JGoTextEdit is a JGoControl object, which is responsible for creating a JTextComponent, either a JTextField or a JTextArea. You’ll want to replace or modify JGo’s implementation of those editors, which are internal classes named “JGoJTextField” and “JGoJTextArea”.
You may be able to find on the web some good examples of how to customize those Swing text editor components. Such customization doesn’t have anything to do with JGo.

Hi Walter;
Is it possible to have sample code of how to put my JTextComponent into JGoText.doStartEdit to replace JGoTextField and JGoTextArea?
I have no problem to subclass JTextComponent but do not know how to integrate with JGo.

Well, the easiest thing to do is to define your own subclass of JTextComponent to behave the way you want and change the definition of JGoTextEdit.createComponent to create an instance of your JTextComponent subclass. Look at how JGoJTextArea, for example, is defined, and how it interacts with the definition of paint, which you might also want to override in order to customize how it sizes the JTextComponent.

Additionally it would be interesting to know which way to go to make for example a JGoTextNode autofit to its text.

Actually, if JGoTextNode.isAutoResize() is true, JGoTextNode does change the size of the Background object, and thus of the whole node itself, as the text in the JGoText label changes.
Perhaps you mean something else?

That doesn’t work very well with empty JGoTextNodes that should be resizable by the user. AutoResize would make sense (in my case) if the text would not fit otherwise.

Maybe that’s a trivial one… I currently have to dig a bit into code I wrote quite a while ago, so I guess I have work myself into JGo again. Maybe the picture gets a bit clearer this time, with a little distance…