title: Attaching images to JLabel's border
body: <p>I want to write a custom subclass of JLabel that would have two images attached to the border, that can be moved by moving the mouse. Real effects like this:</p>
  
  <p><a href="https://i.stack.imgur.com/Lnn0X.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Lnn0X.png" alt="https://i.stack.imgur.com/Lnn0X.png"></a></p>
  
  <p>Here's my subclass, how could I add these attached images?</p>
  
  <pre><code>public class Rect extends JLabel{
      private int width,height;
      public Rect (int width,int height){
          this.width = width;
          this.height = height;
          setText("b1");
          repaint();
      }
  
      public void paintComponent(Graphics g){
          super.paintComponent(g);
  
          g.setColor(Color.red);
          g.drawRect(0, 0, this.width, this.height);
      }
  
      public void reDraw(){
          this.repaint();
      }
  
      public void setWidth(int width) {
          this.width = width;
          repaint();
      }
  
      public void setHeight(int height) {
          this.height = height;
          repaint();
      }
  }
  </code></pre>