dialog.getComponents()返回值总为1

public class JFrameStudy {
    public static void main(String[] args) {
        JFrame frame = new JFrame("JFrame");
        JButton btn1 = new JButton("模态对话框");
        JButton btn2 = new JButton("非模态对话框");
        frame.setSize(300, 300);
        frame.setLocation(300, 300);
        frame.setLayout(new FlowLayout());
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.add(btn1);
        frame.add(btn2);
        frame.setVisible(true);

        final JDialog dialog = new JDialog(frame, "JDialog");
        final JLabel lable = new JLabel();
        final JButton btn3 = new JButton("确定");
        dialog.add(btn3);
        dialog.setSize(150, 150);
        dialog.setLocation(350, 350);
        dialog.setLayout(new FlowLayout());
        System.out.println(dialog.getComponents().length);

        btn1.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                dialog.setModal(false);
                if (dialog.getComponents().length == 1) {
                    dialog.add(lable);
                }
            }
        });
    }
}

dialog.getComponents()不是返回dialog内的组件个数吗,为什么我都添加两个了,返回的数组长度还是1???

frame添加了2个
frame.add(btn1);
frame.add(btn2);
dialog只有1个
dialog.add(btn3);
你在这里输出下dialog.getComponents().length看看