Hi, this is in regard to JGo 531 on Windows XP, JDK 1.6.
I have a set of nodes that are subclassed off of GeneralNode, as I need a variable number of ports, an icon, and a label. One of these node types is called ‘bphFitNode’.
I also have a set of custom edge types, subclassed off of JGoLabeledLink; one of these new edge types is called ‘bphIABLink’.
One of the desired behaviors is that when an instance of the bphIABLink type is inserted into the document from a port on a bphFitNode to some other node, I want to change the icon and the label displayed for the bphFitNode. My current (and failed) attempt at doing this is shown below. The code is invoked when it should be, and the lines of code to change the icon and label do execute, but no visible changes appear. Any idea why this is?
Hmmm. You shouldn’t even need the “myView.repaint()” code. Changing the label and/or the image should automatically repaint the node.
The setIcon and setTopLabel aren't methods defined on GeneralNode so I assume they are defined in bphFitNode. Can you show me the code for these methods?
Scott,
This code is in the my unmodified GeneralNode.Java:
// get the basic parts of a General Node
public JGoText getTopLabel() { return myTopLabel; }
public JGoObject getIcon() { return myIcon; }
I added the corresponding setters:
public void setTopLabel(JGoText myText)
{
myTopLabel = myText;
}
public void setIcon(JGoObject icon)
{
myIcon = icon;
}
What I have also noticed is that some view updating mechanism has become seriously broken, as unless I sprinkle calls to myView.repaint() in several places, even something as basic as just moving a node leaves behind an image in the node’s old position. I’m using Demo1View as my view class and my top-level application frame is largely based on Demo1, which has it’s own custom document and view listeners. I have added my own code in the viewListener that traps selection movement so I can add custom behavior when nodes are moved.
That’s the problem. A GeneralNode is a JGoArea that has several JGoObject children, including the top label and the icon. Changing myTopLabel and myIcon changes these member values, but doesn’t change the label or the icon that has previously been added to the JGoArea.
Instead, you can just change the string and the image associated with these objects with code similar to the following: