Focus cycle inside dockable

Hi Beni,

I noticed a bug in the focus system in the Eclipse theme.
If you run the example below and focus the first text field outside dockable,
you can cycle through all 3 text fields with the tab.
When you start with the first text field inside dockable it stops at the last text field (no cycle).
If you try the same example in the Flat theme, after the last text field the focus goes
to docking buttons and then back to the text fields.

Would it be possible to make the focusing of the docking buttons optional?
The reason is that I sometimes put the same component inside a dockable
and sometimes in a modal JDialog.
With focusing of the docking buttons switched off I could get consistent behavior -
the JDialog only focuses the components inside it…

kind regards,
Maciej Modelski

package test;

import java.awt.Color;

import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextField;

import bibliothek.gui.dock.common.CControl;
import bibliothek.gui.dock.common.CGrid;
import bibliothek.gui.dock.common.CWorkingArea;
import bibliothek.gui.dock.common.DefaultSingleCDockable;
import bibliothek.gui.dock.common.theme.ThemeMap;
import bibliothek.gui.dock.util.Priority;
import bibliothek.gui.dock.util.color.ColorManager;

public class TabTest2
{
  public static void main(String[] args)
  {

    JFrame frame = new JFrame("Test");
    frame.getContentPane().setLayout(new BoxLayout(frame.getContentPane(), BoxLayout.Y_AXIS));
    
    CControl control = new CControl(frame);
    control.setTheme(ThemeMap.KEY_ECLIPSE_THEME);        
    frame.add(control.getContentArea());

    JPanel p1 = new JPanel();
    p1.setBorder(BorderFactory.createTitledBorder("Outside dockable"));
    p1.setLayout(new BoxLayout(p1, BoxLayout.Y_AXIS));
    p1.add(new JTextField());
    p1.add(new JTextField());
    p1.add(new JTextField());
    frame.add(p1);
    

    CWorkingArea work = control.createWorkingArea("work");
    work.setVisible(true);
    work.setMaximizingArea(true);
    work.getStation().setContinousDisplay(true);

    ColorManager colors = control.getController().getColors();
    colors.put(Priority.CLIENT, "paint.insertion.area", Color.RED);
    
    CGrid grid = new CGrid(control);
    JPanel p = new JPanel();
    p.setBorder(BorderFactory.createTitledBorder("Inside dockable"));
    p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
    p.add(new JTextField());
    p.add(new JTextField());
    p.add(new JTextField());
    DefaultSingleCDockable d1 = new DefaultSingleCDockable("work 1", "Work 1", p);
    d1.setCloseable(true);
    grid.add(0, 0, 1, 1, d1);
    work.deploy(grid);
        

    frame.setBounds(20, 20, 600, 600);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setVisible(true);
  }
}

Damn focus… always creating issues.

A quick fix (which I’m not certain if it will work because I’m currently not on a computer with Eclipse and thus cannot test it) would be to put the buttons on some Container (e.g. a JPanel), and call setFocusCycleRoot( true ).

I’m not available during the weekend, but I’ll have a closer look at the focus cycle afterwards. And if possible I’ll add some property to change the behavior.

As always your input is highly welcome, even if I don’t like the fact that I have now more work. :o)

Hi Beni,

thanks, setFocusCycleRoot( true ) solves both problems - the focus
stays inside the dockable and cycles!

As always your input is highly welcome, even if I don’t like the fact that I have now more work.

I post everything that I find, but since the framework’s quality is very high, I don’t find too many bugs :slight_smile:

kind regards,
Maciej Modelski

Good to know.

Btw.: the bug with the Eclipse-Theme is fixed and will be in the next release. Just don’t know yet when to upload it.