SWT Browser Widget with Mozilla (SWT.MOZILLA)

We can use browser inside our java application with SWT browser widget. We can load external HTML pages or websites into our applications using it.

Normal way to initialize browser widget in your application is following.

Browser browser = new Browser(shell, SWT.NONE);

This will create a widget with OS specific browser instance. If you are in windows, Internet Explorer will be your browser host. For Linux default is Mozilla. Personally I don’t like IE much. And there’s a way to load Mozilla to SWT browser widget. Other than that there’s another advantage with using Mozilla, By using Mozilla if you right click nothing will happen inside the application. With IE, users can detect we are using HTML page inside the application. That’s by right click will show the browser specific context menu. Other than that using Mozilla we can get powerful features from Mozilla and XUL runner runtime. Powerful feature with browser widget is we can call JavaScript functions from Java as well as java functions from JavaScript.

There are few steps you have to achieve this goal.

  • Download and install XUL runner.
  • Now you can start with Development of SWT Browser application.
    Just change SWT.
    NONE to SWT.MOZILLA to load Mozilla into the widget.

Introduction to Aspects

Application-context.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans
 xmlns="http://www.springframework.org/schema/beans"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xmlns:aop="http://www.springframework.org/schema/aop"
 xsi:schemaLocation="http://www.springframework.org/schema/beans
 http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
 http://www.springframework.org/schema/aop
 http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">

 <aop:aspectj-autoproxy />

 <bean name="firstAspect"/>

 <bean name="helloWorld"/>

</beans>

Read the rest of this entry »