Here you can find the source of buildManualsMenu(File appDir)
static JMenu buildManualsMenu(File appDir)
//package com.java2s; //License from project: Open Source License import java.awt.Desktop; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.File; import javax.swing.JMenu; import javax.swing.JMenuItem; public class Main { static JMenu buildManualsMenu(File appDir) { JMenu manuals = new JMenu("Manuals"); File manualsDir = new File(appDir.getPath() + File.separatorChar + "manual"); if (manualsDir.exists() && manualsDir.isDirectory()) { for (File manualDirContent : manualsDir.listFiles()) { if (manualDirContent.isDirectory()) { for (final File manual : manualDirContent.listFiles()) { if (manual.getName().contains(".pdf")) { JMenuItem manualAction = new JMenuItem( manualDirContent.getName()); manualAction .addActionListener(new ActionListener() { @Override public void actionPerformed( ActionEvent e) { try { Desktop.getDesktop().open( manual); } catch (Exception exception) { exception.printStackTrace(); } } });/*from w w w . j a v a 2 s . c o m*/ manuals.add(manualAction); } } } } } return manuals; } }