title: InputDialog showing up multiple times
body: <p>I am trying to add text to my paint program, but I have some trouble with it. 
  This is what I want: a person clicks somewhere in the frame, an inputdialog shows up where the person can type in their text and after clicking OK, the text will show up at the clicked location.
  First of all I get a copy of the dialog showing up at the left upper corner after I pressed OK. Like this: <a href="https://i.stack.imgur.com/Zxwm6.jpg" rel="nofollow noreferrer">inputdialog</a></p>
  
  <p>Second of all: the first time adding text works fine, but the second time the inputdialog shows up twice and I have to fill in the text twice before it shows up on the frame. The third time I have to do it 3 times and so on... </p>
  
  <p>This are parts of my code:</p>
  
  <pre><code>    public class MyTexfield implements drawable {
  
          private double x1, y1, x2, y2;
  
          public void MyTextfield() {
          }
  
          public void MyTextfield (double x1, double y1, double x2, double y2) {
              this.x1 = x1;
              this.y1 = y1;
              this.x2 = x2;
              this.y2 = y2;
          }
  
          @Override
          public void draw(Graphics2D g) {
              double x = getStartX();
              double y = getStartY();
              String text = JOptionPane.showInputDialog("Your text here", null);
              g.drawString(text, (int)x, (int)y);
  
          }
  
  public class DrawPanel extends JPanel {
  
      Color fillColor = null;
      List&lt;drawable&gt; shapesList = new ArrayList&lt;drawable&gt;();
      int prevx;
      int prevy;
  
      DrawPanel() {
          super();
      }
  
      @Override
      public void paintComponent(Graphics g) {
          super.paintComponent(g);
          // Cast the graphics object to type Graphics2D
          Graphics2D g2d = (Graphics2D) g;
          for (drawable s : shapesList)
              s.draw(g2d);
      }
      public void addText(int x, int y, int z, int a)
          {
              MyTexfield textField = new MyTexfield();
              shapesList.add(textField);
              textField.setCoordinates(x,y,z,a);
              repaint();
          }
  </code></pre>
  
  <p>Hope someone can help!</p>