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.remove(0);
content.add(new JScrollPane( new JTextArea("This is the swapped component.") ));
((DefaultMultipleCDockable)dock).setTitleText("Swapped");
}
And call swapComp() method as follows:
swapComp(dock);
The code seems to work. Is this the right way to handle it?
Regards,
Roger