Avatar of ionutcib
ionutcib
Flag for Romania asked on

How can I integrate swt browser into my SWING application?

How can I integrate SWT browser into my SWING application?
Java

Avatar of undefined
Last Comment
ionutcib

8/22/2022 - Mon
isprabu

SWT itself is a GUI library like Swing. And SWT Browser is part of the SWT library. Unlike Swing, SWT is platform specific (ex; Windows).
So, why don't you use SWT for the your GUI development too?
I have given below a raw sample code using SWT only here. Hope this might be useful OR pardon me if you already knew this....

hope this helps!
public static void main(String [] args) { 
            Display display = new Display(); 
		//create a SWT window
            Shell shell = new Shell(display); 
            shell.setLayout(new  
	    FillLayout()); 
		//create the browser 
            WebKitBrowser browser= new WebKitBrowser(shell, SWT.NONE); 
            browser.setUrl(<home page URL here>); 
            shell.open(); 
            while (!shell.isDisposed()) { 					 
                if (!display.readAndDispatch())
                    display.sleep(); 
            }
       }

Open in new window

ASKER CERTIFIED SOLUTION
isprabu

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ionutcib

ASKER
I already have an application in swing and it will be difficult to translate all in swt now(or it will not?)
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy