This is very similar to my last question, but doing it in a JPanel I am trying to display a JEditorPane inside a JPanel (fixed size) which then displays a string of HTML text. (This is so I can use a cardlayout and switch panels with different displays). I can get everything displaying again, though it seems that the text inside the HTML string I pass into my EditorPane doesn't cut off and wrap to a new line. i.e it just extends off the screen. It seems that the setSize method has no bearing on the size of the Pane?
I am making this app for different size screen so it is important that the text wraps to new lines and fits the screen size rather than run off! It works when the EditorPane is directly inside a JFrame but not JPanel.
JEditorPane pane = new JEditorPane();
pane.setEditable(false);
HTMLDocument htmlDoc = new HTMLDocument () ;
HTMLEditorKit editorKit = new HTMLEditorKit () ;
pane.setEditorKit (editorKit) ;
pane.setSize(size);
pane.setMinimumSize(size);
pane.setMaximumSize(size);
pane.setOpaque(true);
pane.setText("<b><font face=\"Arial\" size=\"50\" align=\"center\" > Unfortunately when I display this string it is too long and doesn't wrap to new line!</font></b>");
bg.add(pane, BorderLayout.CENTER);
Many thanks Sam