title: Merging images in JPanel
body: <p>I was trying to build a tinder clone project by using Java Swing. What I am trying to do is that when I clicked on people's images in the JPanel where I'd added people who were matched with the logged user, I wanna display an <strong>X</strong> icon which is gonna delete the user from my database and JTable when it's clicked on.</p>
  <p>My JTable looks like:</p>
  <p><a href="https://i.stack.imgur.com/4z8J5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4z8J5.png" alt="https://i.stack.imgur.com/4z8J5.png" /></a></p>
  <p>I've tried to approach from multiple aspects but I could not certainly figure out what to do. How am I gonna create a new Label which is the <strong>X</strong> icon under the clicked picture in the JPanel?</p>
  <p>My code while adding matched people's pictures to the JPanel:</p>
  <pre><code>ResultSet rs = st.executeQuery(&quot;select id_liked from tinder.likes where id_user = &quot; + Login.loggedUser.id);
      
      while (rs.next()) {
          
          ResultSet rs2 = st2.executeQuery(&quot;select id_liked from tinder.likes where id_user = &quot; + rs.getInt(1));
          
          while (rs2.next()) {
              
              if(rs2.getInt(1) == Login.loggedUser.id) {
                  System.out.println(&quot;if'in içi&quot;);
                  
                  ResultSet rs3 = st3.executeQuery(&quot;select id, name from tinder.users where id = &quot; + rs.getInt(1));
                  rs3.next();
                  
                  JLabel person = new JLabel(rs3.getString(2));
                  person.setIcon(new ImageIcon(conn.getPhoto(rs3.getInt(1)).getScaledInstance(100, 100, Image.SCALE_SMOOTH)));
                  person.setToolTipText(rs3.getInt(1) + &quot;&quot;);
                  person.setFont(new Font(&quot;Yu Gothic UI Light&quot;, Font.BOLD, 11));
                  person.setVerticalTextPosition(SwingConstants.BOTTOM);
                  person.setHorizontalTextPosition(SwingConstants.CENTER);
                  person.addMouseListener(new MouseAdapter() {
                      @Override
                      public void mouseEntered(MouseEvent e) {
                          Border border = BorderFactory.createLineBorder(Color.BLUE, 1);
                          person.setBorder(border);
                      }
                      public void mouseExited(MouseEvent e) {
                          person.setBorder(null);
                      }
                      public void mouseClicked(MouseEvent e) {
                          System.out.println(person.getToolTipText());
                      }
                  });
                  panel.add(person);
               
                  break;
              }
              
          }
      }
  </code></pre>