We are flipping back and forth between 1.3.1 and 1.4.1 right now. We wanted
to handle a change from requestFocus used in 1.3.1 and prior to
requestFocusInWindow. We have a number of our own classes that extend Swing
Components so we thought we could over-ride requestFocusInWIndow so that it
would work whether we compiled in 1.3.1 or 1.4.1.

We though we might do the following:


public boolean requestFocusInWindow(){
  if (IS_JRE_1_3){
    requestFocus();                     
    return false;               
  }
  try{
    java.lang.reflect.Method requestFocusInWindow =
super.getClass().getMethod("requestFocusInWindow",null);
    Object result = requestFocusInWindow.invoke((JButton)this,null); //
.invoke(super,null); doesn't compile
    return ((Boolean)result).booleanValue(); 
  }
  catch(Exception e){
    return false;
  }
}

My question is will the invoke statement actually invoke the
JButton.requestFocusInWindow or will it recurse into this sub-class method?

To change your JDJList options, please visit: http://www.sys-con.com/java/list.cfm

Reply via email to