このコードを動作させようとしています (アプレット) は、webrenderer トライアルに基づいています。このコードは、例のセクションで取得しました。
そこでサイトを検索してみましたが、役に立ちませんでした。アプレットでページをレンダリングしたいです。以下は私が使用した完全なコードです。何が間違っているのか本当にわかりません。
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import com.webrenderer.swing.*;
/**
* This example shows how to set up WebRenderer to run Java Applets
*
* @author JadeLiquid Software.
* @see www.webrenderer.com
*/
public class AppletExample
{
// instance of a browser
IMozillaBrowserCanvas browser;
JTextField textfield;
public AppletExample()
{
// Creates a JFrame to host the browser
JFrame frame = new JFrame("Applet Example");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// Create and append the browser
frame.setContentPane(createContent());
frame.setSize(640, 480);
frame.setVisible(true);
}
public JPanel createContent()
{
JPanel panel = new JPanel(new BorderLayout());
textfield = new JTextField();
panel.add(BorderLayout.NORTH, textfield);
// The action listener triggers when text is entered in the text field
textfield.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
browser.loadURL(textfield.getText());
}
});
// If you are behind a proxy server, it may be necessary to set the proxy authentication
// to enable access for page loading. Enable the following call(s) with the appropriate
// values for domain, port..
// These settings will need to be applied to both the browser and to enable applets.
//int yourProxyPort = 8080;
//String yourProxyServer = "proxyserver";
// Apply proxy settings to enable applets. Username and password will need to entered as
// a dialog does not appear automatically as is the case with the browser proxy.
//BrowserFactory.setAppletProxySettings(yourProxyServer, String.valueOf(yourProxyPort));
//BrowserFactory.setAppletProxyAuthentication("username", "password");
// Create a browser instance
browser = BrowserFactory.spawnMozilla();
// Required if a proxy server is being used.
//browser.setProxyProtocol(new ProxySetting( ProxySetting.PROTOCOL_ALL, yourProxyServer, yourProxyPort));
//browser.enableProxy();
// Required call to allow applets to function
browser.setAppletMode(IMozillaBrowserCanvas.ENABLE_JAVA_APPLETS);
// Load a site with many applet examples
browser.loadURL("java.sun.com/applets/jdk/1.4/index.html");
// Attach to the panel
panel.add(BorderLayout.CENTER, browser.getComponent());
return panel;
}
public static void main(String[] args)
{
/*
* TODO: Insert your username and key in the following setLicenseData call.
* WebRenderer operates with reduced functionality if the username and key are not correct.
* The sample key used below is a limited-duration trial key.
*/
BrowserFactory.setLicenseData( "30dtrial" , "9Q2QFT9JIK4OHO5BSNKHNMM9EMTR5NRG" );
new AppletExample();
}
}
実行しようとすると、エラーが発生します
java.lang.reflect.InvocationTargetException
ここにデバッグ情報があります
Initializing jdb ...
Internal exception:
java.io.IOException: The handle is invalid
at java.io.FileInputStream.readBytes(Native Method)
at java.io.FileInputStream.read(FileInputStream.java:242)
at java.io.BufferedInputStream.read1(BufferedInputStream.java:273)
at java.io.BufferedInputStream.read(BufferedInputStream.java:334)
at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:283)
at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:325)
at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:177)
at java.io.InputStreamReader.read(InputStreamReader.java:184)
at java.io.BufferedReader.fill(BufferedReader.java:154)
at java.io.BufferedReader.readLine(BufferedReader.java:317)
at java.io.BufferedReader.readLine(BufferedReader.java:382)
at com.sun.tools.example.debug.tty.TTY.<init>(TTY.java:751)
at com.sun.tools.example.debug.tty.TTY.main(TTY.java:1067)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at sun.applet.Main.invokeDebugger(Main.java:314)
at sun.applet.Main.run(Main.java:143)
at sun.applet.Main.main(Main.java:98)