2012-10-26 21 views
2

我們有一個Java應用程序顯示一個嵌入式網頁。 這是使用NativeSwing jwebbrowser完成的,但嵌入式瀏覽器原來是IE7,所以我們遇到了樣式問題。 該機器安裝了IE8,所以我希望它成爲默認瀏覽器。需要Jwebbrowser使用最新的瀏覽器

這是圖書館的限制嗎?有沒有辦法選擇瀏覽器版本?

謝謝。

+1

不是一個真正的答案,所以我只是把它作爲評論,但http://sourceforge.net/p/djproject/discussion/671154/thread/53b1c1ad/線程似乎相關。 – PhiLho

+0

你有沒有想出一個解決方案呢? – nilgun

+0

不,現在我們已經轉移到Mac,因此它使用Webkit。但我們仍然不確定最終會使用什麼系統。 – Omiod

回答

2

經過一段時間的工作,我設法運行jwebbrowser與系統上安裝的最新版本的Internet Explorer(IE9)。

該問題與SWT版本有關,並在The SWT FAQ中描述。 對我來說,包括this link和DJNativeSwing.jar和DJNativeSwing-SWT.JAR從this link的SWT.JAR和運行下面的代碼

/* 
* Christopher Deckers ([email protected]) 
* http://www.nextencia.net 
* 
* See the file "readme.txt" for information on usage and redistribution of 
* this file, and for a DISCLAIMER OF ALL WARRANTIES. 
*/ 
package chrriis.dj.nativeswing.swtimpl.demo.examples.webbrowser; 

import java.awt.BorderLayout; 
import java.awt.FlowLayout; 
import java.awt.event.ItemEvent; 
import java.awt.event.ItemListener; 

import javax.swing.BorderFactory; 
import javax.swing.JCheckBox; 
import javax.swing.JComponent; 
import javax.swing.JFrame; 
import javax.swing.JPanel; 
import javax.swing.SwingUtilities; 

import chrriis.common.UIUtils; 
import chrriis.dj.nativeswing.swtimpl.NativeInterface; 
import chrriis.dj.nativeswing.swtimpl.components.JWebBrowser; 

/** 
    * @author Christopher Deckers 
    */ 
public class SimpleWebBrowserExample { 

     public static JComponent createContent() { 
      JPanel contentPane = new JPanel(new BorderLayout()); 
      JPanel webBrowserPanel = new JPanel(new BorderLayout()); 
      webBrowserPanel.setBorder(BorderFactory.createTitledBorder("Native Web Browser component")); 
      final JWebBrowser webBrowser = new JWebBrowser(); 
      webBrowser.navigate("http://www.browserproperties.com"); 
      webBrowserPanel.add(webBrowser, BorderLayout.CENTER); 
      contentPane.add(webBrowserPanel, BorderLayout.CENTER); 
      // Create an additional bar allowing to show/hide the menu bar of the web browser. 
      JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 4, 4)); 
      JCheckBox menuBarCheckBox = new JCheckBox("Menu Bar", webBrowser.isMenuBarVisible()); 
      menuBarCheckBox.addItemListener(new ItemListener() { 
      public void itemStateChanged(ItemEvent e) { 
       webBrowser.setMenuBarVisible(e.getStateChange() == ItemEvent.SELECTED); 
      } 
      }); 
      buttonPanel.add(menuBarCheckBox); 
      contentPane.add(buttonPanel, BorderLayout.SOUTH); 
      return contentPane; 
     } 

     /* Standard main method to try that test as a standalone application. */ 
     public static void main(String[] args) { 
      NativeInterface.open(); 
      UIUtils.setPreferredLookAndFeel(); 
      SwingUtilities.invokeLater(new Runnable() { 
       public void run() { 
        JFrame frame = new JFrame("DJ Native Swing Test"); 
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 
        frame.getContentPane().add(createContent(), BorderLayout.CENTER); 
        frame.setSize(800, 600); 
        frame.setLocationByPlatform(true); 
        frame.setVisible(true); 
       } 
      }); 
      NativeInterface.runEventPump(); 
     } 
}  

結束顯示:

您正在使用 的Internet Explorer 基本信息 瀏覽器名稱:Internet Explorer的 瀏覽器版本:9.0 平臺:WINDOWS ... (您可能需要刷新一次或兩次,以避免緩存)

+0

我們終於對它進行了測試,並且能夠正常工作。謝謝! – Omiod

相關問題