title: How to add text over an image in a JFrame?
body: <p>Hello I want to create a program that takes information and displays it over an image in a custom location or points that I set for it. I've tried different things but they do not work or display a frame. Basically, I am wondering how to add text over the image. Thanks!</p>
  
  <pre><code>/*
   * This program will ask information to be displayed in four different pieces of documentation.
   */
  
  package choice.assignment;
  
  import java.io.IOException;
  import javax.swing.ImageIcon;
  import javax.swing.JFrame;
  import static javax.swing.JFrame.EXIT_ON_CLOSE;
  import javax.swing.JLabel;
  import javax.swing.JOptionPane;
  import javax.swing.JPanel;
  
  /*
   * @author Talha
   */
  
  public class ChoiceAssignment extends JFrame {
  
      public static void main(String[] args) {
          String option = JOptionPane.showInputDialog("Enter the type of document you want to receive:");
          if ("passport".equals(option)) {
              String country = JOptionPane.showInputDialog(null, "Which country's passport would you like?");
              String name = JOptionPane.showInputDialog(null, "What is you name?");
              String countryOfOrigin = JOptionPane.showInputDialog(null, "What is you country of origin?");
              String dateOfBirth = JOptionPane.showInputDialog(null, "What is your date of birth?");
              new ChoiceAssignment().getPassport(option, country, name, countryOfOrigin, dateOfBirth);
          }
      }
  
      public void getPassport(String option, String country, String name, String countryOfOrigin, String dateOfBirth) {
          if ("usa".equals(country)) {
              JFrame frame = new JFrame();
              JPanel panel = new JPanel();
              JLabel label = new JLabel();
              frame.setTitle("USA Passport");
              frame.setSize(300, 400);
              frame.setVisible(true);
              frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
              label.setIcon(new ImageIcon("uspassport.jpg"));
              panel.add(label);
              frame.add(panel);
              frame.validate();
      }
  }
  </code></pre>