如何在JLabels中应用换行符?

Pea*_*Gen 2 java user-interface swing jlabel

请查看以下代码

 JLabel menuItemTitle =  new JLabel("How to Find Waist");
     JLabel  menuItemDescription = new JLabel("Take the Neck measurement with your shoulders down and relaxed.\n Looking straight ahead rap the tape around the smallest point, below the Larynx, and sloping down slightly toward the front.\nTry a few spots to get the lowest number, and where it feels the most natural.");

        JPanel northPanel = new JPanel();
        northPanel.setLayout(new FlowLayout(FlowLayout.CENTER));
        northPanel.add(menuItemTitle);

        JPanel centerPanel = new JPanel();
        centerPanel.setLayout(new FlowLayout());
        centerPanel.add(menuItemDescription);


        JDialog dialog = new JDialog();
        dialog.setLayout(new BorderLayout());
        dialog.add(northPanel,"North");
        dialog.add(centerPanel,"Center");

                dialog.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
                dialog.setLocationRelativeTo(null);
                dialog.pack();
                dialog.setVisible(true);
Run Code Online (Sandbox Code Playgroud)

我添加了所需的转义字符,但它没有破坏该行.如何在JLabels中添加LineBreaks?我也尝试过使用HTML.但那也失败了.请帮忙.

更新

HTML版本

menuItemDescription = new JLabel("<html>Take the Neck measurement with your shoulders down and relaxed.</br> Looking straight ahead rap the tape around the smallest point, below the Larynx, and sloping down slightly toward the front.</br>Try a few spots to get the lowest number, and where it feels the most natural.</html>");
Run Code Online (Sandbox Code Playgroud)

Upe*_*apu 5

您可以通过这种方式在JLabel中使用HTML代码

JLabel label = new JLabel("<html>Welcome to<br>Stackoverflow</html>");
Run Code Online (Sandbox Code Playgroud)