Reputation: 477
I'm trying to use the DJ Native Swing API to open a WebBrowser on my code:
public class YoutubeViewer {
public static void main(String[] args) {
NativeInterface.open();
SwingUtilities.invokeLater(new Runnable() {
public void run() {
JFrame frame = new JFrame("YouTube Viewer");
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.getContentPane().add(getBrowserPanel(null), BorderLayout.CENTER);
frame.setSize(800, 600);
frame.setLocationByPlatform(true);
frame.setVisible(true);
}
});
NativeInterface.runEventPump();
// don't forget to properly close native components
Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
@Override
public void run() {
NativeInterface.close();
}
}));
}
public static JPanel getBrowserPanel(String trailer) {
trailer = "https://www.youtube.com/watch?feature=player_detailpage&v=6kw1UVovByw";
JPanel webBrowserPanel = new JPanel(new BorderLayout());
JWebBrowser webBrowser = new JWebBrowser();
webBrowserPanel.add(webBrowser, BorderLayout.CENTER);
webBrowser.setBarsVisible(false);
webBrowser.navigate(trailer);
return webBrowserPanel;
}
}
But I keep getting this error:
Could anyone help me?
Upvotes: 0
Views: 415
Reputation: 26
This kind of exception is caused when the class loader (module of the interpreter) do not locate the respective class (SWTNativeInterface, in your case) in the class path. You should place the respective library in the project's classpath.
You set this classpath in the project properties.
Upvotes: 1