void () { // The history size PLUS choices size must be below `maxVisibleRows` // (note that the history size is always lower than `maxVisibleRows`, // and that it should be, if possible, equal to 'maxPopupHistory') // In addition, the history should not show any of the choices that // are visible, when all choices can be displayed at once int historySize = historyModel.clearRestrictions(); // restrict none int choicesSize = choicesModel.getSize(); int maxChoices = Math.min(choicesSize, maxVisibleRows - historySize); if ((historySize > 0) && (choicesSize <= maxChoices)) { for (int i = 0; i < choicesSize; i++) { if (historyModel.restrict(choicesModel.getElementAt(i))) { --historySize; } } maxChoices = choicesSize; } boolean showHistory = historySize > 0; boolean showChoices = maxChoices > 0; choicesScrollPane.setVisible(showChoices); historyScrollPane.setVisible(showHistory); if (showHistory) { historyList.setVisibleRowCount(historySize); historyScrollPane.setPreferredSize(null); } if (showChoices) { // in fact, there are always choices choicesList.setVisibleRowCount(maxChoices); choicesScrollPane.setPreferredSize(null); } separator.setVisible(showHistory && showChoices); }