0
我有一个JEditorPane在一个窗口中的矩形内,因此它不会填满整个窗口。但是,当HTML页面变得太大时,它会将其切断,而不是放入滚动条,我知道我需要JScrollpane或其他东西,但我不希望整个窗口中的滚动条只在矩形内。在JEditorPane中的滚动条在一个矩形中
这里是我的代码片段(rweb已经被定义为一个矩形):
JEditorPane web = new JEditorPane();
web.setEditable(false);
try {
web.setPage("http://www.google.com");
}catch (IOException e) {
web.setContentType("text/html");
web.setText("<html>Could not load webpage</html>");
}
web.addHyperlinkListener(new HyperlinkListener() {
public void hyperlinkUpdate(HyperlinkEvent e) {
if(e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
if(Desktop.isDesktopSupported()) {
try {
Desktop.getDesktop().browse(e.getURL().toURI());
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (URISyntaxException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
}
}
});
rweb = new Rectangle(0, 0, width, 600);
web.setBorder(null);
web.setBounds(rweb);
window.add(web);