Combo Box

I have a ComboBox in a panel.

  1. If I click anywhere on the panel that has the ComboBox (to bring focus to the panel) and then press the “drop down” part of the ComboBox, the ComboBox drops down correctly.

  2. But if user clicks on another panel (in the same app), then click on the “drop down” part of the ComboBox, the ComboBox drops open and closes again (though the focus is now changed to this panel, and pressing the drop-down again makes it work ok)

The problem doesn’t happen if I don’t use the docking grids.

Does anyone know a fix for this?

Sample code:


import javax.swing.*;

import bibliothek.gui.DockFrontend;
import bibliothek.gui.Dockable;
import bibliothek.gui.dock.DefaultDockable;
import bibliothek.gui.dock.SplitDockStation;
import bibliothek.gui.dock.station.split.SplitDockGrid;

public class Dock {
    public static void main(String[] args) {
        JFrame frame = new JFrame("Demo");
        DockFrontend frontend = new DockFrontend(frame);
        SplitDockStation station = new SplitDockStation();

        frame.add(station.getComponent());
        frontend.addRoot(station, "station");

        SplitDockGrid grid = new SplitDockGrid();
        grid.addDockable(0, 0, 1, 1, createDockable("Red", Color.RED));
        grid.addDockable(0, 1, 1, 1, createDockable("Green", Color.GREEN));
        grid.addDockable(1, 0, 1, 1, createDockable("Blue", Color.BLUE));
        grid.addDockable(1, 1, 1, 1, createDockable("Yellow", Color.YELLOW));
        station.dropTree(grid.toTree());

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

    public static Dockable createDockable(String title, Color color) {
        JPanel panel = new JPanel();
        panel.setOpaque(true);
        panel.setBackground(color);
        JComboBox combo = new JComboBox(new String[]{"aaaa", "bbbb", "cccc", "aaaa", "bbbb", "cccc"});
        panel.setLayout(new FlowLayout());
        panel.add(combo);
        return new DefaultDockable(panel, title);
    }

}```
Toggle Highlighting[Open in New Window](http://www.experts-exchange.com/codeSnippetPopup.jsp?csid=7840473)Select All

I think that is the new focus management which wants to focus another Component. It does not affect “normal” Components but the JComboBox somwhat depends on not losing the focus. I’ll fix this ASAP, and upload a new version somewhere during the weekend.