chakri bobby

Greenhorn
+ Follow
since Sep 19, 2007
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by chakri bobby

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
13 years ago