Check out example codes for "java confirmation dialog". It will help you in understanding the concepts better.

Code Example 1

int dialogResult = JOptionPane.showConfirmDialog(frame, "Text", "Title", JOptionPane.YES_NO_OPTION);
if(dialogResult == JOptionPane.YES_OPTION){
  	// Do something
}

Learn ReactJs, React Native from akashmittal.com