Is there anyway to "pack" a JPanel?

MattS picture MattS · Oct 6, 2014 · Viewed 12.8k times · Source

Is there any thing I can do to make my JPanel pack like a JFrame, or do something like that. I want to do this instead of giving it dimensions. Please comment if any addition info is needed. Thanks.

Answer

georges abitbol picture georges abitbol · Mar 29, 2018

Please try JPanel.updateUI and let me know if that helps.

You should make GUI calls in the Event Dispatcher Thread:

EventQueue.invokeLater(() -> {
    someJPanel.updateUI();
});