Reputation: 29
For some reason my JLabel
isn't displaying and I can't figure out why
(editString DOES have a value).
compFrame.removeAll();
JPanel editPane = new JPanel();
editPane.setLayout(new GridLayout(0,1));
compFrame.add(editPane);
//JLabel lastValue = new JLabel(editString);
editPane.add(new JLabel(editString));
compFrame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
compFrame.setVisible(true);
Upvotes: 1
Views: 46
Reputation: 481
you should use removeAll on ContentPane. Try this
compFrame.getContentPane().removeAll();
The API doc for removeAll says:
This method changes layout-related information, and therefore, invalidates the component hierarchy. If the container has already been displayed, the hierarchy must be validated thereafter in order to reflect the changes.
Upvotes: 1