/** {@inheritDoc} */ @Override public void actionPerformed(ActionEvent ae) { final String command = ae.getActionCommand(); if (command == null) return; switch (command) { case OK: if (!verifyNewTradeRoute()) return; // Return to TradeRoutePanel, which will add the route // if needed, and it is valid. super.actionPerformed(ae); break; case CANCEL: cancelTradeRoute(); break; default: super.actionPerformed(ae); break; } }