class FindFailedDialog extends JDialog implements ActionListener {

  JButton retryButton;
  JButton skipButton;
  JButton abortButton;
  FindFailedResponse _response;
  boolean isCapture = false;

  public FindFailedDialog(org.sikuli.script.Image target) {
    init(target, false);
  }

  public FindFailedDialog(org.sikuli.script.Image target, boolean isCapture) {
    init(target, isCapture);
  }

  private void init(org.sikuli.script.Image target, boolean isCapture) {
    this.isCapture = isCapture;
    setModal(true);
    JPanel panel = new JPanel();
    panel.setLayout(new BorderLayout());
    Component targetComp = createTargetComponent(target);
    panel.add(targetComp, BorderLayout.NORTH);
    JPanel buttons = new JPanel();
    String textRetry = "Retry";
    if (isCapture) {
      textRetry = "Capture";
    }
    String textSkip = "Capture/Skip";
    if (isCapture) {
      textSkip = "Skip";
    }
    retryButton = new JButton(textRetry);
    retryButton.addActionListener(this);
    skipButton = new JButton(textSkip);
    skipButton.addActionListener(this);
    abortButton = new JButton("Abort");
    abortButton.addActionListener(this);
    buttons.add(retryButton);
    buttons.add(skipButton);
    buttons.add(abortButton);
    panel.add(buttons, BorderLayout.SOUTH);
    add(panel);
    setDefaultCloseOperation(DISPOSE_ON_CLOSE);
    addWindowListener(new WindowAdapter() {
      @Override
      public void windowClosing(WindowEvent e) {
        _response = FindFailedResponse.ABORT;
      }
    });
  }

  @Override
  public void actionPerformed(ActionEvent e) {
    if (retryButton == e.getSource()) {
      _response = FindFailedResponse.RETRY;
    } else if (abortButton == e.getSource()) {
      _response = FindFailedResponse.ABORT;
    } else if (skipButton == e.getSource()) {
      _response = FindFailedResponse.SKIP;
    }
    dispose();
  }

  public FindFailedResponse getResponse() {
    return _response;
  }

  <PatternString> Component createTargetComponent(org.sikuli.script.Image img) {<FILL_FUNCTION_BODY>}

  @Override
  public void setVisible(boolean flag) {
    if (flag) {
//TODO Can not be called in the constructor (as JFRrame?)
// Doing so somehow made it impossible to keep
// the dialog always on top.
      pack();
      setAlwaysOnTop(true);
      setResizable(false);
      setLocationRelativeTo(this);
      requestFocus();
    }
    super.setVisible(flag);
  }
}

    JLabel cause = null;
    JPanel dialog = new JPanel();
    dialog.setLayout(new BorderLayout());
    if (img.isValid()) {
      if (!img.isText()) {
        Image bimage = img.get();
        if (bimage != null) {
          String rescale = "";
          JLabel iconLabel = new JLabel();
          int w = bimage.getWidth(this);
          int h = bimage.getHeight(this);
          if (w > 500) {
            w = 500;
            h = -h;
            rescale = " (rescaled 500x...)";
          }
          if (h > 300) {
            h = 300;
            w = -w;
            rescale = " (rescaled ...x300)";
          }
          if (h < 0 && w < 0) {
            w = 500;
            h = 300;
            rescale = " (rescaled 500x300)";
          }
          bimage = bimage.getScaledInstance(w, h, Image.SCALE_DEFAULT);
          iconLabel.setIcon(new ImageIcon(bimage));
          cause = new JLabel("Cannot find " + img.getName() + rescale);
          dialog.add(iconLabel, BorderLayout.PAGE_END);
        }
      } else {
        cause = new JLabel("Sikuli cannot find text:" + img.getName());
      }
    }
    if (isCapture) {
      cause = new JLabel("Request to capture: " + img.getName());
    }
    dialog.add(cause, BorderLayout.PAGE_START);
    return dialog;
  
<methods>public void <init>() ,public void <init>(java.awt.Frame) ,public void <init>(java.awt.Dialog) ,public void <init>(java.awt.Window) ,public void <init>(java.awt.Frame, boolean) ,public void <init>(java.awt.Frame, java.lang.String) ,public void <init>(java.awt.Dialog, boolean) ,public void <init>(java.awt.Dialog, java.lang.String) ,public void <init>(java.awt.Window, java.awt.Dialog.ModalityType) ,public void <init>(java.awt.Window, java.lang.String) ,public void <init>(java.awt.Frame, java.lang.String, boolean) ,public void <init>(java.awt.Dialog, java.lang.String, boolean) ,public void <init>(java.awt.Window, java.lang.String, java.awt.Dialog.ModalityType) ,public void <init>(java.awt.Frame, java.lang.String, boolean, java.awt.GraphicsConfiguration) ,public void <init>(java.awt.Dialog, java.lang.String, boolean, java.awt.GraphicsConfiguration) ,public void <init>(java.awt.Window, java.lang.String, java.awt.Dialog.ModalityType, java.awt.GraphicsConfiguration) ,public javax.accessibility.AccessibleContext getAccessibleContext() ,public java.awt.Container getContentPane() ,public int getDefaultCloseOperation() ,public java.awt.Component getGlassPane() ,public java.awt.Graphics getGraphics() ,public javax.swing.JMenuBar getJMenuBar() ,public javax.swing.JLayeredPane getLayeredPane() ,public javax.swing.JRootPane getRootPane() ,public javax.swing.TransferHandler getTransferHandler() ,public static boolean isDefaultLookAndFeelDecorated() ,public void remove(java.awt.Component) ,public void repaint(long, int, int, int, int) ,public void setContentPane(java.awt.Container) ,public void setDefaultCloseOperation(int) ,public static void setDefaultLookAndFeelDecorated(boolean) ,public void setGlassPane(java.awt.Component) ,public void setJMenuBar(javax.swing.JMenuBar) ,public void setLayeredPane(javax.swing.JLayeredPane) ,public void setLayout(java.awt.LayoutManager) ,public void setTransferHandler(javax.swing.TransferHandler) ,public void update(java.awt.Graphics) <variables>protected javax.accessibility.AccessibleContext accessibleContext,private int defaultCloseOperation,private static final java.lang.Object defaultLookAndFeelDecoratedKey,protected javax.swing.JRootPane rootPane,protected boolean rootPaneCheckingEnabled,private javax.swing.TransferHandler transferHandler