/** * Set the content and visibility of menu items and menu separator, * based on the recent file stored user preferences. */ private static void updateMenuItems(List<JComponent> menuItems) { // Update the menu items for (int i = 0; i < NUMBER_OF_MENU_ITEMS; i++) { // Get the menu item JMenuItem recentFile = (JMenuItem) menuItems.get(i); // Find and set the file for this recent file command String recentFilePath = getRecentFile(i); if (recentFilePath != null) { File file = new File(recentFilePath); String sb = String.valueOf(i + 1) + " " + //$NON-NLS-1$ getMenuItemDisplayName(file); // Index before file name recentFile.setText(sb); recentFile.setToolTipText(recentFilePath); recentFile.setEnabled(true); recentFile.setVisible(true); } else { recentFile.setEnabled(false); recentFile.setVisible(false); } } }