row.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent f){ try{ String magic = f.paramString(); rowvalue = Integer.parseInt(f.paramString()); } catch(NumberFormatException e){ JOptionPane.showMessageDialog(new JFrame(), "Goofed.", "Consequences will never be the same.", JOptionPane.ERROR_MESSAGE); } } });