title: Creating border around ImageIcon on a JLabel, not around the Jlabel
body: <p><img src="https://i.stack.imgur.com/3cWio.jpg" alt="alt text"></p>
  
  <p>I have problem with creating border for an icon in JLabel. I have JPanel in which I set it into GridLayout. I added Jlabel on the JPanel. The size of the JLabel were according to the size of the icon. However when I tried to set the border on the icon, it created border according to the size of the grid and not the size of the icon inside the grid. </p>
  
  <p>How can I create a border around the image not on the size of the grid?</p>
  
  <p><strong>Why the border followed the size of the grid and not the size of the imageIcon?</strong></p>
  
  <pre><code>JPanel panel= new JPanel(new GridLayout(ROWS,COLS,2,2)); 
  panel.setsize(600,600);
  
  ....
  JLabel = new JLabel(icon, JLabel.LEFT);
  label.setVerticalAlignment(SwingConstants.TOP);
  ...
  label.setborder(BorderFactory.createLineBorder(Color.RED,5));
  panel.add(label);
  </code></pre>