Mike said:
The title pretty much says it all. I've created a class that extends
JPanel and have attempted to place a JScrollPane inside of it with a
JEditorPane inside the scroll pane with no luck. When I run the
applet the scroll pane shows up but the JEditorPane doesn't render. I
am able to nest a JTextArea inside the scroll pane just fine.
Thanks for you help,
Mike
A Java Noob
Well, the short answer is "yes," but I think it requires some tinkering. See
http://java.sun.com/docs/books/tutorial/uiswing/components/example-1dot4/index.html#TextSamplerDemo
or if you're not at 1.4 yet
http://java.sun.com/docs/books/tutorial/uiswing/components/example-swing/TextSamplerDemo.java
Here is a short example: not an applet, but that at least shows it's
possible...
//==========
package news.exp;
import javax.swing.JEditorPane;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
public class Main {
private static String DOC =
"<html><head>Testing some scrolling</head>" +
"<body><h1>Hello World!</h1>" +
"<p>An editor pane inside a scroll pane.</p></body></html>";
public static void main(String[] args) {
JFrame frame = new JFrame("Test the scrollers");
JPanel panel = new JPanel();
JEditorPane editor = new JEditorPane("text/html", DOC) {
// See justification in javax.swing.Scrollable
public boolean getScrollableTracksViewportWidth() {
return false;
}};
JScrollPane scroller =
new JScrollPane(
editor,
JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
panel.add(scroller);
frame.getContentPane().add(panel);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.show();
}
}
//========
HTH!
Sean.