I have a JFrame that I create in the main function. I want to add a JTextField to it. The problem I'm having is that the JFrame is created and then - with about a second delay - the JTextField is added. Is there a way I can draw the text field to my window and then show all at once? Thanks in advance!
For reference, here is my code:
public class Window {
public static final JFrame window = new JFrame();
public static final JTextField input = new JTextField();
private static void loadWindow(){
window.setSize(800, 600);
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
window.setLayout(new FlowLayout());
input.setPreferredSize(new Dimension(400, 60));
window.add(input);
window.setVisible(true);
}
public static void main(String[] args){
loadWindow();
}
}
Here's the timeline of what's happening:
First second:
Second after: