答案 0 :(得分:0)
This is a short example for my application.
List<Menu> menuItems = new ArrayList<>();
for (File file : files) {
Menu menuItem = new Menu();
menuItem.setLabel(file.getName());
menuItem.setName(file.getPath());
menuItems.add(menuItem);
menuItem.addActionListener(newMenuItemClickActions(menuItem));
}