I use GridBagConstraints to update my layout, when a button have been clicked, some input fields will appear.
private class EventListener implements ActionListener {
public void actionPerformed(ActionEvent e) {
input_panel.removeAll();
String str = e.getActionCommand();
System.out.print(str);
JLabel jl = new JLabel("Label ");
// Create constraints
GridBagConstraints textFieldConstraints = new GridBagConstraints();
GridBagConstraints labelConstraints = new GridBagConstraints();
labelConstraints.gridx = 0;
labelConstraints.gridy = 0;
input_panel.add(jl,textFieldConstraints);
}
}
This function successfully runs, however, there is a strange problem, when I click the button, it do update, but not show immediately, I must need to resize the window to see it. What happens?