File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "problem with browser Listener in linux" Watch "problem with browser Listener in linux" New topic
Author

problem with browser Listener in linux

chakri bobby
Greenhorn

Joined: Sep 19, 2007
Posts: 1
Hi
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.setBounds(5,5,600,600);


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();
shell.close();
}
});
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";
browser.execute(jScript);
}

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();} ";
browser.execute(jScript1);

}
});
shell.open();

while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
}


and jsp is
<HTML>

<HEAD>



</HEAD>

<BODY >

<FORM >

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

</FORM>

</BODY></HTML>

thanks in advance
Rob Camick
Ranch Hand

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

1) Still not using "Code" tags

2) Cross posting: http://forums.sun.com/thread.jspa?threadID=5442083&tstart=0

Be Forthright When Cross Posting To Other Sites
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem with browser Listener in linux