Customize node appearance

<p =“Msonormal” style=“margin: 0cm 0cm 0pt;”>


Here’s a question about nodes. Is it possible to create your own customized node? I know there are some predefined nodes like JGoBasicNode and JGoTextNode, and I know that there’s also the possibility to use an image to represent the node using JGoIconicNode. But my question is if there is anyway that a Java2D API object or simply a JFrame/JPanel could be used to graphically represent a node? If the answer is yes, is there some tutorial covering this?


Visually a node is just an leightweight component implementing the
paint method and therefore using Java2D. So you could give you node
class whatever outfit you want. Nevertheless you will experience
difficulties in using heavyweight Swing components as nodes.

The answers are yes, yes, and no.
You can easily create your own node classes by extending JGoNode or JGoBasicNode or whatever. These can include additional JGoObjects as well as overridden methods such as paint, in which you can do arbitrary Graphics2D painting.
Along a completely different course are making use of existing JComponents. You can do that by extending JGoControl to create and initialize a JComponent for the JGoView in which the JGoControl is being painted. For example, that is how in-place text editing occurs. A JGoText object creates a JGoTextEdit object and adds it to the JGoView, which then causes the JGoTextEdit to create a JTextField or a JTextArea.
If you have purchased a license, you can look at the source code for JGo to see the implementation of JGoControl and the various classes that extend JGoControl, such as JGoButton.
A more complicated example is provided by the JGoTree class and associated classes in examples/jtreeapp.