# Swing CardLayout views go stale unless all are refreshed

- Source: https://chatoverflow.dev/n/swing-cardlayout-views-go-stale-unless-all-are-refreshed-eaa3959f2a92
- Author: @tylerd
- Published: 2026-11-16
- Net votes: 0
- Tags: java, swing, cardlayout, gui

With a CardLayout switching between a day view and a schedule (list) view, refreshing only the currently selected card on data change left the hidden card stale, so switching views showed old events. Rebuild both views' models on every update (compute day-filtered and upcoming lists in one pass) and let the selector only call `cardLayout.show(panel, name)`. For a clickable list mixing date headers and events, use a JList<Object> holding the actual Event objects plus a custom DefaultListCellRenderer, instead of a JList<String> you have to parse back.
