Hiding Labels

Sorry for all the newb questions. I have a set of nodes in a palette and the user can drag those to the view. Pretty standard. When they are in the palette I do not want the text label to show and when they are dropped on the map I want it to show up. I got that working by just setting the visable flag on the label but when they are in the palette they still take up the room as if the label was there. I tried setting the size of the Node object id the text is hidden but that didn’t work. What would the right way be to do this. TIA.

Add a new constructor to your node with a boolean parameter. If set to
true, you add the label to your node, if false, you don’t.

In the palette, add the node using Node(false) (not adding the label to
the node’s children). Override your view’s drop() method. Make it
something like this:

public void drop(DropTargetDropEvent e) {
JGoOject obj = (JGoObject) e.getTransferable().getTransferData(JGoDocument.getStandardD ataFlavor())
if (obj instanceof YourNode) {
getDocument().addObjectAtTail(new YourNode(true));
}
super.drop(e);
}

I think “AlArenal” has a good idea, but I suspect that that implementation of JGoView.drop might not even run without an error, and would cause there to be duplicate nodes if it did complete. It doesn’t handle a drop of multiple nodes either.
The basic idea is to create the objects in the JGoPalette without labels, and then add those labels when the objects are dropped onto the JGoView/JGoDocument.
You can do that without even overriding any JGoView methods by defining a JGoViewListener that looks for the JGoViewEvent.EXTERNAL_OBJECTS_DROPPED hint. Then iterate through the selection, which should be all of the objects that were copied into the document, and add the appropriate label to each one.

Just out of curiosity what would be the best node type to use? Currently I am using JIconicNode as the base class for my node type but it has some very wierd behavior if I create the label seperatly. (The labels don’t show up under the node)

To create it, call new JGoIconicNode(null) , which will initialize the node normally, except there won’t be a Label.
Later, call node.setLabel(node.createLabel(“some text”)) .

I tried creating the node passing in Null for the string but after I set the icon it still allows space for the label when I add it to the palette.
startTaskPaletteIcon = new JGoIconicNode(null);
JGoImage taskImage = new JGoImage(new Rectangle(0, 0, 24, 24));
taskImage.loadImage(new URL(buildURLString(startIconUrl)), true);
startTaskPaletteIcon.setIcon(taskImage);

I am just going to try something else at this point. Maybe a toolbar since I have to override and/or handle the drop on the view anyways.