title: Java GUI popup menus
body: <p>I'm beginner in Java GUI and have a problem to design a popup menu. I have a JPanel and want to have a popup menu with just two alternatives. Here is my code:</p>
  
  <pre><code>        ActionListener ordermethod = new ActionListener() {
              public void actionPerformed(ActionEvent e) {
                  throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
              }
          };
  
          JPopupMenu popup = new JPopupMenu();
  
          JMenuItem arr = new JMenuItem("first");
          arr.addActionListener(ordermethod);
          popup.add(arr);
          arr = new JMenuItem("second");
          arr.addActionListener(ordermethod);
          popup.add(arr);
          myPanel.add(new JLabel("Pattern ordering method:"), gbc);
          myPanel.add(arr, gbc);
  </code></pre>
  
  <p>but the problem is that when I run the code, we see the JLabel and and a box that shows "second" and when I click on the "second" to find "first", get a long list of errors. (this is some parts of errors)</p>
  
  <pre><code>Exception in thread "AWT-EventQueue-0" java.lang.UnsupportedOperationException: Not supported yet.
  at main.Main$1.actionPerformed(Main.java:53)
  at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018)
  at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341)
  at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
  at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
  </code></pre>
  
  <p>Hopefully the problem is clear and you can help me. Thanks.</p>