title: How to create a rounded title border in Java Swing
body: <p>I do understand that to create a title border, you do something like:</p>
  
  <pre><code>BorderFactory.createTitledBorder("  Your Title  ");
  </code></pre>
  
  <p>However this creates a rectangle border whereas I need a rectangle with curved corners. </p>
  
  <p>Now from what I understand you can create your own custom border by:</p>
  
  <pre><code>class CustomBorder implements Border
  {
    ...
  }
  </code></pre>
  
  <p>The problem is that I'm not sure how to write the code that overrides the method:</p>
  
  <pre><code>public void paintBorder(Component component, Graphics g, int x, int y, int width, int height)
  </code></pre>
  
  <p>Or better yet, is there a way to do it without implementing your own Border class? And if not, how would you write that custom Title Border? I'm ok with drawing a rectangle with rounded corners, but how do you do it so that there's space for the label too?</p>