Replace component of a Dock

Hello Beni,

Is the following the correct DF way to swap a component of a dock?
Standard create dock method of:

private DefaultMultipleCDockable createDock(String id, String title)
   DefaultMultipleCDockable dock = new DefaultMultipleCDockable( null );
   dock.add( new JScrollPane( new JTextArea() ) );
   return dock;

And I call it with:

MultipleCDockable dock = createDock("thing01", "Something Cool");

Now, if I give the user the option to switch the JTextArea to another JTextArea.

I can delete the existing component and add a new component by doing:

private void swapComp(MultipleCDockable dock)
   Container content = ((DefaultCDockable)dock).getContentPane();
   content.add(new JScrollPane( new JTextArea("This is the swapped component.") ));

And call swapComp() method as follows:


The code seems to work. Is this the right way to handle it?


That is fine, everything below the “content pane” belongs to your application and the framework will never add/replace/remove anything that is on the content pane.