Trying to throw Exceptions in method called in an ActionListener
<p>So I am unsure why I am getting an error when trying to call a method with an action listener for a button. I created the panel and set the layout to flow layout, and then added it to the content pane, and then created the button here...</p>

<pre><code>JButton buyButton = new JButton("Buy");
    panel.add(buyButton);
    buyButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {buy();}});
</code></pre>

<p>I then created a try catch block in the buy method...</p>

<pre><code>public void buy throws OverException
{
    try{
       //tries the code
    }
    catch(OverException e){
      //does stuff...
    }
}
</code></pre>

<p>But it keeps saying that it must be caught or declared to be thrown in the method calling of buy() when creating the button.</p>