title: Java: Text not wrapping in JFrame dialog
body: <p>I'm using a JFrame to present a message box with some text and 2 buttons. How do I get the text to wrap automatically based on the size of the box?</p>
  
  <p>Here's my current code:</p>
  
  <pre><code>        dialogFrame = new JFrame();
  
          JButton newButton = new JButton("New");
          newButton.addActionListener(new newUploadAction());
  
          JButton resumeButton = new JButton("Resume");
          resumeButton.addActionListener(new resumeUploadAction());
  
          //dialogFrame.setUndecorated(true);
  
          JPanel addPanel = new JPanel();
  
          JPanel addPanel2 = new JPanel();
  
          addPanel.add(newButton);
          addPanel.add(resumeButton);
  
          String text = "&lt;html&gt;&lt;p&gt;A previous control file exists for this file. ";
          text += "Would you like to initiate a new transfer or resume the previous one?&lt;/p&gt;&lt;/html&gt;";
  
          JLabel testLabel = new JLabel(text);
  
          //testLabel.setPreferredSize(new Dimension(1, 1)); 
  
          addPanel2.add(testLabel);
  
  
          Container content = dialogFrame.getContentPane();
  
  
          //content.setBackground(Color.white);
          content.setLayout(new BoxLayout(content, BoxLayout.PAGE_AXIS)); 
  
          content.add(addPanel2);
          content.add(addPanel);
  
  
          dialogFrame.setSize(200,200);
          dialogFrame.setVisible(true);
          dialogFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  </code></pre>
  
  <p>I read somewhere that calling</p>
  
  <pre><code>  testLabel.setPreferredSize(new Dimension(1, 1)); 
  </code></pre>
  
  <p>would cause the wrapping behavior I want, but that just resulted in the text not showing up at all.</p>