You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using version 0.13 from Maven. The following code throws StackOverflowError apparently because of an infinite loop. As I explained in the comments, this can be reproduced only if pack is not called.
importcom.formdev.flatlaf.FlatDarculaLaf;
importcom.formdev.flatlaf.FlatIntelliJLaf;
importjavax.swing.*;
importjava.awt.BorderLayout;
importjava.awt.Window;
publicclassUpdateComponentTreeProblem {
publicstaticvoidmain(String[] args) {
SwingUtilities.invokeLater(UpdateComponentTreeProblem::runOnEDT);
}
privatestaticvoidrunOnEDT() {
setLaf(newFlatDarculaLaf());
JFramef = newJFrame("Test");
f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
f.setLayout(newBorderLayout());
JComboBox<String> themeChooser = newJComboBox<>(newString[]{"Light", "Dark"});
themeChooser.setName("themeChooser");
themeChooser.setSelectedItem("Dark");
themeChooser.addActionListener(e -> {
StringthemeName = (String) themeChooser.getSelectedItem();
if(themeName.equals("Light")) {
setLaf(newFlatIntelliJLaf());
}
});
f.add(themeChooser, BorderLayout.NORTH);
f.add(newJLabel("Change the theme to \"Light\"!"));
// In order to reproduce the problem,// it is crucial NOT to call pack().// In a real app the window size could be read// from the saved preferences and set manually.// f.pack();f.setSize(600, 400);
f.setLocationRelativeTo(null);
f.setVisible(true);
}
privatestaticvoidsetLaf(LookAndFeellaf) {
try {
UIManager.setLookAndFeel(laf);
} catch (UnsupportedLookAndFeelExceptione) {
e.printStackTrace();
}
Window[] windows = Window.getWindows();
for (Windowwindow : windows) {
SwingUtilities.updateComponentTreeUI(window);
}
}
}
The text was updated successfully, but these errors were encountered:
I am using version 0.13 from Maven. The following code throws StackOverflowError apparently because of an infinite loop. As I explained in the comments, this can be reproduced only if pack is not called.
The text was updated successfully, but these errors were encountered: