Component currFocus = null;
KeyboardFocusManager.getCurrentKeyboardFocusManager().addPropertyChangeListener(
new PropertyChangeListener(){
public void propertyChange(PropertyChangeEvent e){
String prop = e.getPropertyName();
if ((prop.equals("focusOwner"))){
if(e.getNewValue() != null){
currFocus = (Component)e.getNewValue();
}
}
}
}
);
Showing posts with label java. Show all posts
Showing posts with label java. Show all posts
Wednesday, July 03, 2013
Tracking focus in Java
After a lot of experimenting I found a reliable way to track which controls are getting focus:
Wednesday, August 08, 2012
Catching HTTP 401/403 using Java SWT IE Browser
I've been working on a bit of Java code which needs to handle an HTTP proxy authentication failure, the code in question uses IE via the SWT browser and unfortunately I've discovered that you cannot chain onto the NavigateError event!
The event is handled inside IE.java (SWT source) but just does some specialised UNC handling without giving you the opportunity to do something useful (like catch the HTTP status code). As such I've had to restort to using an additional connection using HttpURLConnection and Authenticator.setDefault() / getPasswordAuthentication() - which is wasteful as I'm now having to make two connections to the webserver...
It's not even as if you can derive a new class from org.eclipse.swt.browser.IE because the required member variables have default visibility which means anything outside the org.eclipse.swt.browser package can't access them :(
The event is handled inside IE.java (SWT source) but just does some specialised UNC handling without giving you the opportunity to do something useful (like catch the HTTP status code). As such I've had to restort to using an additional connection using HttpURLConnection and Authenticator.setDefault() / getPasswordAuthentication() - which is wasteful as I'm now having to make two connections to the webserver...
It's not even as if you can derive a new class from org.eclipse.swt.browser.IE because the required member variables have default visibility which means anything outside the org.eclipse.swt.browser package can't access them :(
Labels:
401,
403,
auth,
http,
IE,
java,
NavigationError,
org.eclipse.swt.browser,
swt
Subscribe to:
Posts (Atom)