Repainting contents of a dockable

Hi,

First of all, thank you for the great framework!

I think I’ve hit a wall with something and hoping someone can help me out. I have a CButton that opens up a dialog that performs modification to the content of the dockable. The contents of the dockable do not update until I mouse over the CButton again or any other action button. I think it has something to do with focus. The dockable doesnt seem to repaint itself until it gets focused somehow. I tried giving it focus directly, but that didnt work. Below is the code to illustrate my problem. I am using 1.0.8 version of the framework. Thanks in advance.

package tmp;

import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;

import org.apache.commons.lang.RandomStringUtils;

import bibliothek.gui.dock.common.CControl;
import bibliothek.gui.dock.common.CGridArea;
import bibliothek.gui.dock.common.CLocation;
import bibliothek.gui.dock.common.DefaultSingleCDockable;
import bibliothek.gui.dock.common.action.CButton;

public class DockingFrameTest extends JFrame {

	public DockingFrameTest(){
		super("Test");
		
		final CControl control = new CControl(this);
		CGridArea center = control.createGridArea("center");
		
		add( center.getComponent() );		
		this.setBounds(200, 200, 200, 200);
		
		JLabel lable = new JLabel("Start");
		
		final DefaultSingleCDockable dockable = new DefaultSingleCDockable( "test" , "test" , lable ) ;
		dockable.setCloseable(true);
		dockable.setMinimizable(false);
		
		CButton edit = new CButton() {
			@Override
			protected void action() {
				
				final JTextField text = new JTextField();
				JDialog d = new JDialog();
				d.getContentPane().add(text);
				d.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
				d.addWindowListener(new WindowAdapter(){
					public void windowClosed(WindowEvent evt) {
						dockable.getContentPane().removeAll();
						dockable.getContentPane().add(new JLabel(text.getText()));
					}
				});
				d.pack();
				d.setLocationRelativeTo(DockingFrameTest.this);
				d.setVisible(true);
				
				
				
			}
		};		
		edit.setText("edt");
		dockable.addAction(edit);
		
		control.add(dockable);
		dockable.setLocation(CLocation.base().normalEast(0.5));
		dockable.setVisible(true);
		
		
		
	}
	

	public static void main(String[] args) {
		DockingFrameTest test = new DockingFrameTest();
		test.setVisible(true);
	}
}

I think this is a bug of Swing, not of the framework. Because the code below does not work either and uses only original Swing components. As a workaround: call “revalidate” on the content pane after you added the new components, like this:
((JComponent)dockable.getContentPane()).revalidate();


import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;

public class Dock46 extends JFrame {

	public Dock46(){
		super("Test");
		
		JLabel lable = new JLabel("Start");
		getContentPane().add( lable );
		
		JButton edit = new JButton("Edit");
		edit.addActionListener( new ActionListener() {
			@Override
			public void actionPerformed( ActionEvent e ){
				final JTextField text = new JTextField();
				JDialog d = new JDialog();
				d.getContentPane().add(text);
				d.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
				d.addWindowListener(new WindowAdapter(){
					public void windowClosed(WindowEvent evt) {
						Dock46.this.getContentPane().removeAll();
						Dock46.this.getContentPane().add(new JLabel(text.getText()));
//						((JComponent)dockable.getContentPane()).revalidate();
					}
				});
				d.pack();
				d.setLocationRelativeTo(Dock46.this);
				d.setVisible(true);
			}
		});	
		
		setBounds( 20, 120, 300, 200 );
		
		JDialog dialog = new JDialog( this );
		dialog.add( edit );
		dialog.setBounds( 20, 20, 300, 100 );
		dialog.setVisible( true );
	}
	

	public static void main(String[] args) {
		Dock46 test = new Dock46();
		test.setVisible(true);
	}
}```

Works like a charm. Thanks a lot!