Try calling revalidate () on the object you want to update (in your case, the second frame).
Example:
JButton myButton = new JButton("Open new window");
JFrame newFrame = new JFrame("New Window");
myButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
newFrame.pack();
newFrame.setVisible(true);
newFrame.revalidate();
}
});
Update
If this does not work, try calling:
newFrame.invalidate();
newFrame.validate();
source
share