title: Pop Up Text Field Java
body: <p>I have a button and on click I want it to load a text field (like a pop up). Is this possible?</p>
  
  <p>I've looked into</p>
  
  <pre><code>this.setVisible(false);
  new className().setVisible(true);
  </code></pre>
  
  <p>But this means I'd need a new JFrame. I'm not against the idea - I'm just asking if there is a better way of doing it. If possible, I want it to load JUST a text field instead of a the frame that is around it.</p>
  
  <p>I've just created JOptionPane as suggested below - But i'm still having problems. The pop up appears, but nothing is included in the box.</p>
  
  <p>When mouse is clicked on class 1:</p>
  
  <pre><code>JOptionPane.showMessageDialog(this, MetaData.getTags());
  </code></pre>
  
  <p>class 2 (I'm aware this isn't the best way to throw exceptions. This is only a rough program). Using <a href="http://www.drewnoakes.com/code/exif/" rel="nofollow">metadata extractor</a> for those who are interested.</p>
  
  <pre><code>public String getTags() {
          try {
              Metadata metadata = ImageMetadataReader.readMetadata(jpegFile);
  
              for (Directory directory : metadata.getDirectories()) {
                  for (Tag allTags : directory.getTags()) {
                      System.out.println("MetaData Class: " + allTags);
                  }
              }
          } catch (ImageProcessingException ex) {
              Logger.getLogger(MetaData.class.getName()).log(Level.SEVERE, null, ex);
          } catch (IOException ex) {
              Logger.getLogger(MetaData.class.getName()).log(Level.SEVERE, null, ex);
          }
          return allTags;
      }
  </code></pre>