I have a JFrame class
public class SettingsFrame extends JFrame {
 public FirstSettingsFrame() throws HeadlessException {
    setTitle("Settings");
    setSize(600, 400);
    ...
    JButton searchModels = new JButton("Start");
    searchManyModels.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            JFrame frame = new JFrame();
            frame.setSize(new Dimension(800, 600));
            frame.setLayout(null);
            frame.setVisible(true);
            for (int i = 0; i < 10; i++) {
                try {
                    Thread.sleep(800);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                JButton button = new JButton("Test");
                button.setBounds(i * 10, i * 10, 20, 20);
                frame.add(button);
                System.out.println("i = " + i);
            }
        }
    });
 add(searchModels);
 ...
}
Nothing is added, while loop is processing. All buttons are added only when loop is finished. And i want them to be added while looping. How can i manage this?
EDITED:
And this code
 @Override
        public void actionPerformed(ActionEvent actionEvent) {
            JFrame frame = new JFrame();
            JPanel panel = new JPanel();
            frame.setSize(new Dimension(800, 600));
            frame.add(panel);
            frame.pack();
            frame.setVisible(true);
            for (int i = 0; i < 10; i++) {
                try {
                    Thread.sleep(800);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                JButton button = new JButton("Test");
                button.setBounds(i * 10, i * 10, 20, 20);
                panel.add(button);
                panel.revalidate();
                panel.repaint();
                frame.pack();
                System.out.println("i = " + i);
            }
        }
    });
Only changes frame size, not adding anything while looping, too
EDITED 2:
deleting Thread.sleep and writing loop as for (long i = 0; i < 100000000000l; i++) { doesn't affects at all.
 
     
    