JComponent () { myTree.updateUI(); reInitWholePanelIfNeeded(); updateSelectionFromTree(); final JPanel panel = new JPanel(new BorderLayout()) { @Override public Dimension getPreferredSize() { return getPanelPreferredSize(); } }; panel.add(myWholePanel, BorderLayout.CENTER); return panel; }