File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes problem with browser Listener in linux Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "problem with browser Listener in linux" Watch "problem with browser Listener in linux" New topic

problem with browser Listener in linux

chakri bobby

Joined: Sep 19, 2007
Posts: 1
i am new too swt.
i am able to close the opened window after clicking the cancel button in the browser
but the same code is not working in linux window is not closing when i clicked cancel button in the browser.

could you please tell me how to close the window in linux

please find the below code

import org.eclipse.swt.SWT;
import org.eclipse.swt.browser.Browser;
import org.eclipse.swt.browser.CloseWindowListener;
import org.eclipse.swt.browser.LocationEvent;
import org.eclipse.swt.browser.LocationListener;
import org.eclipse.swt.browser.ProgressEvent;
import org.eclipse.swt.browser.ProgressListener;
import org.eclipse.swt.browser.WindowEvent;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.browser.StatusTextEvent;
import org.eclipse.swt.browser.StatusTextListener;

public class test1 {
static String waitURL = "";
static String closeXTS;
public static void main(String[] args) {
Display display = new Display();

final Shell shell = new Shell(display);

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

browser.setUrl("C:\\test.jsp"); ///is for windows
browser.setUrl("/home/chakri/Desktop/test.jsp"); //is for linux
browser.addCloseWindowListener(new CloseWindowListener() {
public void close(WindowEvent event) {
Browser browser = (Browser)event.widget;
Shell shell = browser.getShell();
browser.addStatusTextListener(new StatusTextListener() {
public void changed(StatusTextEvent event) {
System.out.println("1111111" + event.text);

browser.addProgressListener(new ProgressListener() {
public void changed(ProgressEvent progressEvent) {
String jScript = "var ca = document.cookie;\n"
+ "window.status=ca;\n";

public void completed(ProgressEvent progressEvent) { //when the request is completed, process the response
String jScript1 = "var cancel = document.getElementById('cmdCancel');cancel.onclic k=closefix; function closefix(){window.close();} ";


while (!shell.isDisposed()) {
if (!display.readAndDispatch())

and jsp is





<INPUT id=cmdCancel type=button value=Cancel>



thanks in advance
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2280
Different forum, same old stuff:

1) Still not using "Code" tags

2) Cross posting:

Be Forthright When Cross Posting To Other Sites
I agree. Here's the link:
subject: problem with browser Listener in linux