Hi,

I have a scenario where i need to handle user pressing enter key when a ULCAlert alert is shown.

I tried the following .... but it didnt work .. any suggestions to make it work ?
----

Client Part


package com.xxxx.xxx.extension.client;

import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

import javax.swing.JDialog;
import javax.swing.JOptionPane;

import com.ulcjava.base.client.UIAlert;

public class UICustomAlert extends UIAlert {

public void performAction() {
       this.fireWindowClosingULC();
   }
protected void postInitializeState() {
       super.postInitializeState();
   }

   private class HandleEnterKeyListener implements  KeyListener {

       public void keyPressed(KeyEvent e) {
           int code = e.getKeyCode();
           if(code == KeyEvent.VK_ESCAPE){
           // Key pressed is the ESCAPE key. Hide this Dialog.
}
           else if(code == KeyEvent.VK_ENTER){
           //    Key pressed is the ENTER key.
// Redefine performEnterAction() in subclasses to respond to depressing the ENTER key.
               performAction();
}
       }

       public void keyReleased(KeyEvent arg0) {
}

       public void keyTyped(KeyEvent arg0) {
} }

   protected void prepareAlertDialog(JDialog arg0) {
JOptionPane optionPane = (JOptionPane)arg0.getContentPane().getComponent(0);
       KeyListener[] keyListener = optionPane.getKeyListeners();
       for (int i=0;i<keyListener.length;i++) {
           optionPane.removeKeyListener(keyListener[i]);
       }
       optionPane.addKeyListener(new HandleEnterKeyListener());
   }

}

----

Server Part

package com.xxxx.xxx.extension.server;

import com.ulcjava.base.application.ULCAlert;
import com.ulcjava.base.application.ULCRootPane;

public class ULCCustomAlert extends ULCAlert {

   private static final long serialVersionUID = 1L;

public ULCCustomAlert(ULCRootPane rootPane, String loginfailed_title, String login_failed_message, String button_retry, String button_quit) { super(rootPane, loginfailed_title, login_failed_message, button_retry, button_quit);
   }

   protected String typeString() {
return "com.isfsdc.wwm.extension.client.UICustomAlert"; }

}


_______________________________________________
ULC-developer mailing list
[email protected]
http://lists.canoo.com/mailman/listinfo/ulc-developer

Reply via email to