Sorry if this question has been asked many times already, but i have a custom JDialog. It is made so that it has a custom background, and appears over the frame that called it, takes in a message and then should return a YES or NO (0 or 1) upon selecting an option to the frame that called it.
public class JYOptionPane {
@SuppressWarnings("deprecation")
public static void showJY_YES_NO_Dialog(final JFrame frame, String Question) {
    darken(frame);
    frame.disable();
    final JDialog OptionPane = new JDialog();
    OptionPane.setAlwaysOnTop(true);
    OptionPane.setBounds(
            (int) (frame.getX() + (frame.getSize().getWidth() / 2))
                    - (350 / 2), (int) (frame.getY() + (frame.getSize()
                    .getHeight() / 2)) - (200 / 2), 350, 200);
    OptionPane.setResizable(false);
    OptionPane.setUndecorated(true);
    ImageIcon icon = new ImageIcon(
            LoginFrame.class.getResource("/Images/bgprompt.png"));
    Image backImage = icon.getImage();
    ImagePanel contentPane = new ImagePanel();
    contentPane.setBackgroundImage(backImage);
    OptionPane.setContentPane(contentPane);
    OptionPane.setBackground(new Color(0, 0, 0, 0));
    JLabel lblQuestion = new JLabel(Question);
    lblQuestion.setBounds(0, 40, 350, 30);
    lblQuestion.setFont(new Font("Calibria", Font.PLAIN, 20));
    lblQuestion.setForeground(Color.white);
    lblQuestion.setHorizontalAlignment(SwingConstants.CENTER);
    lblQuestion.setVerticalAlignment(SwingConstants.CENTER);
    lblQuestion.setAlignmentY(JComponent.CENTER_ALIGNMENT);
    OptionPane.add(lblQuestion);
    JYButton btnYes = new JYButton(
        new ImageIcon(LoginFrame.class.getResource("/buttons/default.png")),
        new ImageIcon(LoginFrame.class.getResource("/buttons/defaultprs.png")),
        new ImageIcon(LoginFrame.class.getResource("/buttons/defaulthv.png")));
    btnYes.setText("Yes");
    btnYes.setFont(new Font("Arial", Font.BOLD, 17));
    btnYes.setForeground(Color.white);
    btnYes.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            LoginFrame.setOPintNo(0);
            Class<? extends JFrame> f = frame.getClass();
            try {
                f.newInstance().setVisible(true);
                frame.dispose();
            } catch (InstantiationException e) {
                e.printStackTrace();
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            }
            OptionPane.dispose();
        }
    });
    btnYes.setBounds(40, 200 / 2 - 31 / 2 + 50, 121, 31);
    OptionPane.add(btnYes);
    OptionPane.getRootPane().setDefaultButton(btnYes);
    JYButton btnNo = new JYButton(new ImageIcon(
        LoginFrame.class.getResource("/buttons/default.png")),
        new ImageIcon(LoginFrame.class.getResource("/buttons/defaultprs.png")),
        new ImageIcon(LoginFrame.class.getResource("/buttons/defaulthv.png")));
    btnNo.setText("No");
    btnNo.setFont(new Font("Arial", Font.BOLD, 17));
    btnNo.setForeground(Color.white);
    btnNo.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            LoginFrame.setOPintNo(1);
            Class<? extends JFrame> f = frame.getClass();
            try {
                f.newInstance().setVisible(true);
                frame.dispose();
            } catch (InstantiationException e) {
                e.printStackTrace();
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            }
            OptionPane.dispose();
        }
    });
    btnNo.setBounds(189, 200 / 2 - 31 / 2 + 50, 121, 31);
    OptionPane.add(btnNo);
    OptionPane.setVisible(true);
}
}
I tried to let it return an int, but it doesn't seem to be able to assign the int to a variable. Therefore i created an int variable in my LoginFrame (that is never disposed, just invisible) and set it there and created a Get() function for it. However, how do i get the frame to call the Get() function after a selection has been made in the JDialog? It has to be called from the frame that i have passed in as final JFrame frame. Thanks!
 
     
    