title: Java JLabel, break text to next line?
body: <p>It's been awhile since I asked a question!</p>
  
  <p>I'm developing an application in Java where <code>JLabels</code> are used. Anyway, as you may or may not be able to see from the picture below, the text that says <code>Category Test</code> gets cut off and ends up saying <code>Categor...</code> instead. Is there any way that I can "break" the text once it fills up the width of the label? Here is the image:</p>
  
  <p><img src="https://i.stack.imgur.com/O8z8j.png" alt="enter image description here"></p>
  
  <p><strong>What I did</strong></p>
  
  <p>I used a JTextPane like so:</p>
  
  <pre><code>    JTextPane text = new JTextPane();
      SimpleAttributeSet attr = new SimpleAttributeSet();   
  
      StyleConstants.setAlignment(attr, StyleConstants.ALIGN_CENTER);  
  
      pane.add(text, c);
  </code></pre>
  
  <p>Then I added my text, but thanks anyway!</p>