void () { String borderName = null; if (getBorder() instanceof NamedBorder border) { borderName = border.getName(); } setUI(new BasicPanelUI() { @Override protected void installDefaults(JPanel p) {} }); Border updatedBorder = null; if (borderName != null) { updatedBorder = switch (borderName) { case BORDER_WITHOUT_STATUS -> borderWithoutStatus(); case BORDER_WITH_STATUS -> borderWithStatus(); default -> null; // Someone set their own border, leave it alone. }; } if (updatedBorder != null) { setBorder(updatedBorder); } }