Please have a look at the following code
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);
I have added the required escape characters but it is not breaking the line. How can I add LineBreaks in JLabels? I ahve tried the above using HTML as well. But that also failed. please help.
update
html version
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>");
in the html version, you have – Goibniu Jan 02 '13 at 14:32