Hello. I’m having a minor problem with focus in dockingframes. When I create a new DefaultMultipleCDockable, I’d want to set the focus on it, but the title bar is not getting selected. Only the tabs of the CWorkingArea get the focus, but not the dockable’s title bar. In fact, only the first two DefaultMultipleCDockable created are getting the focus correctly. Here’s the code I’m using:
public class Example extends JFrame
{
private CControl control;
private CWorkingArea workingArea;
int dockableCount = 0;
public Example()
{
createMenu();
createDocking();
}
private void createMenu()
{
JMenu fileMenu = new JMenu("File");
JMenuItem newDock = new JMenuItem("New Dock");
newDock.addActionListener(new AbstractAction()
{
@Override
public void actionPerformed(ActionEvent e)
{
DefaultMultipleCDockable dockable = new DefaultMultipleCDockable(null);
dockable.setTitleText(String.format("Dockable: %s", ++dockableCount));
workingArea.add(dockable);
dockable.setVisible(true);
dockable.toFront();
}
});
fileMenu.add(newDock);
JMenuBar menuBar = new JMenuBar();
menuBar.add(fileMenu);
setJMenuBar(menuBar);
}
private void createDocking()
{
control = new CControl(this);
control.setTheme(ThemeMap.KEY_FLAT_THEME);
add(control.getContentArea());
workingArea = control.createWorkingArea("workingArea");
CGrid grid = new CGrid(control);
grid.add(0, 0, 1, 1, workingArea);
control.getContentArea().deploy(grid);
}
public static void main(String[] args)
{
Example example = new Example();
example.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
example.setSize(1200, 800);
example.setLocationRelativeTo(null);
example.setVisible(true);
}
}
Create the first dockable: the tab and the title bar get the focus. Create a second one: also the tab and the title bar get the focus. So far, so good. From now on, for every other dockable created, only the tab is selected, but not the title bar. Am I doing something wrong?
Sebastian.