The initial value/default button for a dialog created with NotifyDescriptor
is not activated when using FlatLAF.
There is an indication around the button requested to be default, but also
some remaining indicator around the actual default button.

FlatLAF works fine when manually creating a dialog with
JOptionPane.showOptionDialog.
MetalLAF works fine with NotifyDescriptor.

The following code displays the problem.
Uncomment to use the workaround.

        var button1 = new JButton("1");
        var button2 = new JButton("2");
        var button3 = new JButton("3");
        var buttons = new JButton[]{button1, button2, button3};

        var d = new NotifyDescriptor(
                "Look at the buttons borders\nPress & hold ENTER",
                "Demo",
                DialogDescriptor.DEFAULT_OPTION,
                DialogDescriptor.WARNING_MESSAGE,
                buttons,
                button3
        );

        new Thread(() -> {
            try {
                Thread.sleep(100);
            } catch (InterruptedException ex) {
                Exceptions.printStackTrace(ex);
            }

            SwingUtilities.invokeLater(() -> {
                //button3.requestFocus();
            });
        }).start();

        System.out.println(DialogDisplayer.getDefault().notify(d));

Patrik

Reply via email to