Home > Back-end >  The Swing embedded JWebBrowser, unable to run under Linux
The Swing embedded JWebBrowser, unable to run under Linux

Time:03-26

Copy the code on the net, there is nothing wrong with run under Windows, but won't run on Linux, error

Failed to create chrriis.dj.nativeswing.swtimpl.com ponents. NativeWebBrowser [1949739] 1
 under Caused by: org. Eclipse SWT. SWTError: No more handles [Unknown Mozilla path (MOZILLA_FIVE_HOME not set)] 
At org. Eclipse SWT. SWT. Error (SWT) Java: 4109)
At org. Eclipse SWT. Browser. Mozilla. InitMozilla (Mozilla. Java: 1739)
At org. Eclipse SWT. Browser. Mozilla. Create (Mozilla. Java: 656)
At org. Eclipse SWT. Browser. The & lt; init> (the Java: 119)
At chrriis.dj.nativeswing.swtimpl.com ponents. NativeWebBrowser. CreateControl (NativeWebBrowser. Java: 402)
. 16 more


Source code for the following
 package com. Wolfgroup. ZLSSF. Client. The screen; 

Import the Java. The awt. *;
The import javax.mail. Swing. *;
The import chrriis.com mon. UIUtils;
The import chrriis. DJ. Nativeswing. Swtimpl. NativeInterface;
The import chrriis.dj.nativeswing.swtimpl.com ponents. JWebBrowser;

Public class ClientScreen extends JPanel {

Private JPanel webBrowserPanel;
Private JWebBrowser webBrowser.

Public ClientScreen (String url) {
Super (new BorderLayout ());

WebBrowserPanel=new JPanel (new BorderLayout ());
The webBrowser=new JWebBrowser ();
The webBrowser. SetButtonBarVisible (false);
The webBrowser. SetMenuBarVisible (false);
The webBrowser. SetBarsVisible (false);
The webBrowser. SetStatusBarVisible (false);
WebBrowserPanel. Add (webBrowser, BorderLayout. CENTER);
Add (webBrowserPanel, BorderLayout. CENTER);

The webBrowser. Navigate (url);
}

Public static void openForm url (String) {
UIUtils. SetPreferredLookAndFeel ();
NativeInterface. The open ();
SwingUtilities. InvokeLater (new Runnable () {
Public void the run () {
JFrame frame=new JFrame ();
Frame. SetDefaultCloseOperation (JFrame. DISPOSE_ON_CLOSE);
Frame. GetContentPane (). The add (new ClientScreen (url));
//frame. SetExtendedState (JFrame. MAXIMIZED_BOTH);
//frame. SetLocationByPlatform (true);

//frame. SetUndecorated (true);
GraphicsEnvironment ge=GraphicsEnvironment. GetLocalGraphicsEnvironment ();
For (ask gd: ge getScreenDevices ()) {
A Rectangle rec=gd. GetDefaultConfiguration (). The getBounds ();
Boolean isDefault=(gd==ge getDefaultScreenDevice ());
System. The out. Println (gd) getIDstring () + "default=" + isDefault);
System. The out. Println (" (" + rec. GetX () + ", "+ rec. GetY () +", "+ rec. GetWidth () +", "+ rec. GetHeight () +") ");
System.out.println();

If (isDefault) {
//frame. SetLocation ((int) rec. GetWidth (), 0).
} else {
//frame. SetSize ((int) rec. GetWidth (), (int) rec. GetHeight ());
//gd. SetFullScreenWindow (frame);
}
//gd. SetFullScreenWindow (frame);
Frame. SetLocation (0, 0);
Frame. SetSize ((int) rec. GetWidth ()/2, (int) rec. GetHeight ()/2);
}
//ask gd=ge. GetDefaultScreenDevice ();
//gd. SetFullScreenWindow (frame);

//frame. GetGraphicsConfiguration (.) getDevice () setFullScreenWindow (frame);

//to form visible
Frame. SetVisible (true);
Frame. SetTitle (" my browser ");

//reset form size
//frame. SetResizable (true);

//set the form of the width and height
//frame. SetSize (1400, 700);

//set the form center
//frame. SetLocationRelativeTo (frame. GetOwner ());
}
});
NativeInterface. RunEventPump ();
}

Public static void main (String [] args) {
//if (args==null | | args. The length!
=1)//throw new RuntimeException (" please specify URL parameter ");

//GraphicsEnvironment ge=GraphicsEnvironment. GetLocalGraphicsEnvironment ();
//if (ge. GetScreenDevices (.) length & lt; 2)
//throw new RuntimeException (" dual monitor ");

//openForm (args [0]);
OpenForm (" http://www.baidu.com ");
}
}

CodePudding user response:


Online to find solutions all from an article that said to install
Sudo apt - get the install libwebkitgtk - 1.0-0

But the results are:
 
Verify success
Is reading package list... Complete the
Are analyzing software package dependency tree
Is reading status information... Complete the
No packages available libwebkitgtk - 1.0-0, but it was cited by the other packages,
This could mean that the missing package may have been abandoned,
Or can only be found in other published sources

E: package libwebkitgtk - 1.0-0 no installable candidate


  • Related