void (TreePath path) { add(myEditorComponent); Rectangle nodeBounds = getPathBounds(path); Dimension editorPrefSize = myEditorComponent.getPreferredSize(); if (editorPrefSize.height > nodeBounds.height) { nodeBounds.y -= (editorPrefSize.height - nodeBounds.height) / 2; nodeBounds.height = editorPrefSize.height; } myEditorComponent.setBounds(nodeBounds); }