// Create an panel with a screen capture button.
JPanel southPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 4, 4));
JButton captureButton = new JButton("Full-page capture");
captureButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String result = (String)webBrowser.executeJavascriptWithResult(
"var width = 0;" + LS +
"var height = 0;" + LS +
"if(document.documentElement) {" + LS +
" width = Math.max(width, document.documentElement.scrollWidth);" + LS +
" height = Math.max(height, document.documentElement.scrollHeight);" + LS +