JFormDesigner / FlatLaf

FlatLaf - Swing Look and Feel (with Darcula/IntelliJ themes support)
https://www.formdev.com/flatlaf/
Apache License 2.0
3.34k stars 266 forks source link

Outer focus border issues on panel's edges #792

Open TLoud opened 8 months ago

TLoud commented 8 months ago

We sometimes use nested panels to build and reuse parts of gui. For these nested panels we use MigLayout with zero insets so these panels wont stand out in terms of sizes and insets. The problem is that outer border isnt painting on the panel's edges.

Here is an example on FlatIntelliJLaf - rootPanel with standard insets with added combobox and two nested panels (zero insets) with one and two components respectively. The focus on the first component looks fine, while others have issues

outer_borders_test

    JPanel rootPanel = new JPanel(new MigLayout("insets n n n n"));

    JPanel nestedPanel1 = new JPanel(new MigLayout("insets 0 0 0 0"));
    nestedPanel1.add(new JComboBox<>(), "grow");

    JPanel nestedPanel2 = new JPanel(new MigLayout("insets 0 0 0 0"));
    nestedPanel2.add(new JComboBox<>(), "grow,wrap");
    nestedPanel2.add(new JTextField(), "grow");

    rootPanel.add(new JComboBox<>(), "grow,wrap");
    rootPanel.add(nestedPanel1,"grow,wrap");
    rootPanel.add(nestedPanel2,"grow");

    JFrame jFrame = new JFrame();
    jFrame.add(rootPanel);
    jFrame.pack();
    jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    jFrame.setResizable(true);
    jFrame.setVisible(true);
TLoud commented 8 months ago

I've looked through this https://github.com/JFormDesigner/FlatLaf/issues/317

Turning off MigLayout visualPadding on nested panels isn't much help here as it usually inflates sizes of other components in same row/column and creates bigger insets between components on nested panel while other insets stay the same

Turning zero insets to non-zero in case of the pic above will create non equal vertical insets between the components

Maybe you are now aware of some other FlatLaf or MigLayout related workarounds? Maybe some MigLayout lifehack, which i can use to keep all the visual insets the same in case of panels with nested zero-insets panels?