0

我想在我的框架中显示一个文件(pdf 文件或图像文件)。我尝试使用 JWebBrowser,但我遇到了例外。这是我的代码:

    JWebBrowser fileBrowser  = new JWebBrowser();
    fileBrowser.setBarsVisible(false);
    fileBrowser.setStatusBarVisible(false);
    jPanel2.add(fileBrowser, BorderLayout.CENTER);
    //fileBrowser.navigate("file:///C:/Users/HP/Desktop/a.pdf");
    fileBrowser.navigate("C:\\Users\\HP\\Desktop\\icon5.jpg");

我得到了这个例外:

Exception in thread "AWT-EventQueue-0" java.lang.ExceptionInInitializerError
at z.zz.createBrowser(zz.java:67)
at z.zz.<init>(zz.java:43)
at z.zz$2.run(zz.java:239)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:733)
at java.awt.EventQueue.access$200(EventQueue.java:103)
at java.awt.EventQueue$3.run(EventQueue.java:694)
at java.awt.EventQueue$3.run(EventQueue.java:692)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:703)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
Caused by:java.lang.RuntimeException: java.lang.ClassNotFoundException: chrriis.dj.nativeswing.swtimpl.components.core.NativeWebBrowserStatic
at chrriis.dj.nativeswing.swtimpl.internal.NativeCoreObjectFactory.create(NativeCoreObjectFactory.java:42)
at chrriis.dj.nativeswing.swtimpl.components.JWebBrowser.<clinit>(JWebBrowser.java:115)
... 17 more Caused by: java.lang.ClassNotFoundException: chrriis.dj.nativeswing.swtimpl.components.core.NativeWebBrowserStatic
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at chrriis.dj.nativeswing.swtimpl.internal.NativeCoreObjectFactory.create(NativeCoreObjectFactory.java:35)
... 18 more
4

0 回答 0