Getting the text from a JMenuItem that is pressed?
<p>Currently using SWING to implement a JMenuBar, where there are 2 different JMenus. One is called gameMenu, and one is called, addMenuGame.</p>

<p>I have several JMenuItems in gameMenu, which are all implemented with this method, in my interface controller.</p>

<pre><code>public void addGameMenu(JMenu control) {
    String fileName = "gamemodes.txt";
    try {

        FileReader inputFile = new FileReader(fileName);

        BufferedReader bufferReader = new BufferedReader(inputFile);

        String line;

        while ((line = bufferReader.readLine()) != null) {

            String split[] = line.split("#");
            for (int i = 0; i &lt; split.length; i++) {
                control.add(split[i]);
            }

        }

        bufferReader.close();
    } catch (Exception e) {
        System.out.println("Fejl ved linje:" + e.getMessage());
    }

} 
</code></pre>

<p>what it does, is read every line from a text file, and adds that to the JMenu, called gameMenu. However, I can only add actionlisteners to the JMenu, and not the JMenuItem, that is of JMenu. In the JFrame main void, this is how I implement it:</p>

<pre><code>public class index extends javax.swing.JFrame {

    QuizzControlHandler dd = new QuizzControlHandler();
    private JMenuItem dc;

    /**
     * Creates new form index
     */
    public index(){

        initComponents();
        dd.addGameMenu(menuGame); 

    }

}
</code></pre>

<p>This will fill my menu correctly, however, I need to retrieve what the user is clicking on. </p>