@Override
    public void actionPerformed(ActionEvent event)
    {
      try
      {
        if (event.getSource() == buy)
        {
          Item item = (Item) merchantsInventory.getSelectedValue();
          
          // select item in merchantsInventory JList
          startSel = merchantsInventory.getSelectedIndex(); 
          endSel = startSel; 
          int nitems = merchantsInventory.getModel().getSize(); 
          if (startSel == nitems - 1) 
          {	
        	  merchantsInventory.setSelectionInterval(startSel - 1, endSel - 1); 
          } 
          else 
          { 
        	  merchantsInventory.setSelectionInterval(startSel + 1, endSel + 1); 
          } 
          
          int money = item.getModifiedPrice();
          
          if (money > thePlayer.getMoney())
          {
            topPlayerLabel.setText("Player can not afford that!");  
          } else
          {
            if(thePlayer.canFitAnotherItem())
            {
            topPlayerLabel.setText("Player");
            merchantList.removeElement(item);
            playerList.addElement(item);
            theMerchant.sale((double) item.getModifiedPrice(), item);
            thePlayer.purchase((double) item.getModifiedPrice(), item);
            updateBanks();
            //item.unModify();  
            repaint();
            }
            else
            {
              topPlayerLabel.setText("Player can not fit any more items!");
            }
          }

        } else if (event.getSource() == sell)
        {
          Item item = (Item) playersInventory.getSelectedValue(); 
          int money = item.getModifiedPrice();  
          if(money > theMerchant.getMoney())
          {
            topMerchantLabel.setText("Merchant can not afford that!");
          } else
          {
            topMerchantLabel.setText("Merchant");
            
            
            // select top item in playerInventory JList
            startSel = playersInventory.getSelectedIndex(); 
            endSel = startSel; 
            int nitems = playersInventory.getModel().getSize(); 
            if (startSel == nitems - 1) 
            { 
            	playersInventory.setSelectionInterval(startSel - 1, endSel - 1); 
            } 
            else 
            { 
            	playersInventory.setSelectionInterval(startSel + 1, endSel + 1); 
            } 
             
            
            playerList.removeElement(item);
            merchantList.addElement(item);
            thePlayer.sale((double) item.getModifiedPrice(), item);
            theMerchant.purchase((double) item.getModifiedPrice(), item);
            updateBanks();
            repaint();
          }

        } else if (event.getSource() == leave)
        {
          dispose();
          // You are welcome -Jon -- Thank you -Ryan
          Orbital loc = ((TradePort) theMerchant).getLocale();
          thePlayer.setLoc(loc.getParent());
        }
      } catch (Exception e)
      {

      }
    }