Help with understanding key event propagation

Hello,
I am hoping someone can help me understand a few things which are not clear to me with respect to handling of key events by Swing components. My understanding is summarized as:
(1) Components have 3 input maps which map keys to actions
one for when they are the focused component
one for when they are an ancestor of the focused component
one for when they are in the same window as the focused component
(2) Components have a single action map which contains actions to be fired by key events
(3) Key events go to the currently focused component
(4) Key events are consumed by the first matching action that is found
(5) Key events are sent up the containment hierarchy up to the window (in which case components with a matching mapping in the WHEN_IN_FOCUSED_WINDOW map are searched for)
(6) The first matching action handles the event which does not propagate further
I have a test class (source below) and I obtained the following console output:
Printing keyboard map for Cancel button
Level 0
Key: pressed C
Key: released SPACE
Key: pressed SPACE
Level 1
Key: pressed SPACE
Key: released SPACE
Printing keyboard map for Save button
Level 0
Key: pressed SPACE
Key: released SPACE
Level 1
Key: pressed SPACE
Key: released SPACE
Printing keyboard map for Main panel
Event: cancel // typed SPACE with Cancel button having focus
Event: save // typed SPACE with Save button having focus
Event: panel // typed 'C' with panel having focus
Event: panel // typed 'C' with Cancel button having focus
Event: panel // typed 'C' with Save button having focus
I do not understand the following aspects of its behaviour (tested on MacOSX although I believe the behaviour is not platform dependent):
(1) I assume that the actions are mapped to SPACE since the spacebar clicks the focused component but I don't explicitly set it?
(2) assuming (1) is as I described why are there two mappings, one for key pressed and one for key released yet the 'C' key action only has a key pressed set?
(3) assuming (1) and (2) are true then why don't I get the action fired twice when I typed the spacebar, once when I pressed SPACE and again when I released SPACE?
(4) I read that adding a dummy action with the value "none" (i.e. the action is the string 'none') should hide the underlying mappings for the given key, 'C' the my example so why when I focus the Cancel button and press the 'C' key do I get a console message from the underlying panel action (the last but one line in the output)?
Any help appreciated. The source is:
import javax.swing.*;
public class FocusTest extends JFrame {
     public FocusTest ()     {
          initComponents();
          setTitle ("FocusTest");
          setLocationRelativeTo (null);
          setSize(325, 160);
          setVisible (true);
     public static void main (String[] args) {
          new FocusTest();
private void initComponents()
     JPanel panTop = new JPanel();
          panTop.setBackground (java.awt.Color.RED);
JLabel lblBanner = new javax.swing.JLabel ("PROPERTY TABLE");
lblBanner.setFont(new java.awt.Font ("Lucida Grande", 1, 14));
lblBanner.setHorizontalAlignment (javax.swing.SwingConstants.CENTER);
          panTop.add (lblBanner);
          JPanel panMain = new JPanel ();
          JLabel lblKey = new JLabel ("Key:");
          lblKey.setFocusable (true);
          JLabel lblValue = new JLabel ("Value:");
JTextField tfKey = new JTextField(20);
JTextField tfValue = new JTextField(20);
JButton btnCancel = new JButton (createAction("cancel"));     // Add a cancel action.
JButton btnSave = new JButton (createAction("save"));          // Add a sve action.
          panMain.add (lblKey);
          panMain.add (tfKey);
          panMain.add (lblValue);
          panMain.add (tfValue);
          panMain.add (btnCancel);
          panMain.add (btnSave);
          add (panTop, java.awt.BorderLayout.NORTH);
          add (panMain, java.awt.BorderLayout.CENTER);
setDefaultCloseOperation (javax.swing.WindowConstants.EXIT_ON_CLOSE);
// Add an action to the panel for the C key.
          panMain.getInputMap (JComponent.WHEN_IN_FOCUSED_WINDOW).put (KeyStroke.getKeyStroke (java.awt.event.KeyEvent.VK_C, 0), "panel");
          panMain.getActionMap ().put ("panel", createAction("panel"));
          // FAILS ???
          // Add an empty action to the Cancel button to block the underlying panel C key action.
btnCancel.getInputMap().put (KeyStroke.getKeyStroke (java.awt.event.KeyEvent.VK_C, 0), "none");
// Print out the input map contents for the Cancel and Save buttons.
System.out.println ("\nPrinting keyboard map for Cancel button");
printInputMaps (btnCancel);
System.out.println ("\nPrinting keyboard map for Save button");
printInputMaps (btnSave);
          // FAILS NullPointer because the map contents are null ???
System.out.println ("\nPrinting keyboard map for Main panel");
// printInputMaps (panMain);
private AbstractAction createAction (final String actionName) {
     return new AbstractAction (actionName) {
          public void actionPerformed (java.awt.event.ActionEvent evt) {
               System.out.println ("Event: " + actionName);
private void printInputMaps (JComponent comp) {
     InputMap map = comp.getInputMap();
     printInputMap (map, 0);
private void printInputMap (InputMap map, int level) {
     System.out.println ("Level " + level);
     InputMap parent = map.getParent();
     Object[] keys = map.allKeys();
     for (Object key : keys) {
          if (key.equals (parent)) {
               continue;
          System.out.println ("Key: " + key);
     if (parent != null) {
          level++;
          printInputMap (parent, level);
Thanks,
Tim Mowlem

Use the [url http://forum.java.sun.com/help.jspa?sec=formatting]Code Formatting Tags so the posted code retains its original formatting.
1) In the Metal LAF the space bar activates the button. In the Windows LAF the Enter key is used to activate the button. Therefore these bindings are added by the LAF.
2) The pressed binding paints the button in its pressed state. The released binding paint the button in its normal state. Thats why the LAF adds two bindings.
In your case you only added a single binding.
3) The ActionEvent is only fired when the key is released. Same as a mouse click. You can hold the mouse down as long as you want and the ActionEvent isn't generated until you release the mouse. In fact, if you move the mouse off of the button before releasing the button, the ActionEvent isn't even fired at all. The mouse pressed/released my be generated by the same component.
4) Read (or reread) the [url http://java.sun.com/docs/books/tutorial/uiswing/misc/keybinding.html#howto]How to Remove Key Bindings section. "none" is only used to override the default action of a component, it does not prevent the key stroke from being passed on to its parent.

Similar Messages

  • I need help with Creating Key Pairs

    Hello,
    I need help with Creating Key Pairs, I generate key pais with aba provider, but the keys generated are not base 64.
    the class is :
    import java.io.*;
    import java.math.BigInteger;
    import java.security.*;
    import java.security.spec.*;
    import java.security.interfaces.*;
    import javax.crypto.*;
    import javax.crypto.spec.*;
    import au.net.aba.crypto.provider.ABAProvider;
    class CreateKeyPairs {
    private static KeyPair keyPair;
    private static KeyPairGenerator pairGenerator;
    private static PrivateKey privateKey;
    private static PublicKey publicKey;
    public static void main(String[] args) throws Exception {
    if (args.length != 2) {
    System.out.println("Usage: java CreateKeyParis public_key_file_name privete_key_file_name");
    return;
    createKeys();
    saveKey(args[0],publicKey);
    saveKey(args[1],privateKey);
    private static void createKeys() throws Exception {
    Security.addProvider(new ABAProvider());
    pairGenerator = KeyPairGenerator.getInstance("RSA","ABA");
    pairGenerator.initialize(1024, new SecureRandom());
    keyPair = pairGenerator.generateKeyPair();
    privateKey = keyPair.getPrivate();
    publicKey = keyPair.getPublic();
    private synchronized static void saveKey(String filename,PrivateKey key) throws Exception {
    ObjectOutputStream out= new ObjectOutputStream(new FileOutputStream(filename));
    out.writeObject(key);
    out.close();
    private synchronized static void saveKey(String filename,PublicKey key) throws Exception {
    ObjectOutputStream out= new ObjectOutputStream( new FileOutputStream(filename));
    out.writeObject(key);
    out.close();
    the public key is:
    �� sr com.sun.rsajca.JSA_RSAPublicKeyrC��� xr com.sun.rsajca.JS_PublicKey~5< ~��% L thePublicKeyt Lcom/sun/rsasign/p;xpsr com.sun.rsasign.anm����9�[ [ at [B[ bq ~ xr com.sun.rsasign.p��(!g�� L at Ljava/lang/String;[ bt [Ljava/lang/String;xr com.sun.rsasign.c�"dyU�|  xpt Javaur [Ljava.lang.String;��V��{G  xp   q ~ ur [B���T�  xp   ��ccR}o���[!#I����lo������
    ����^"`8�|���Z>������&
    d ����"B��
    ^5���a����jw9�����D���D�)�*3/h��7�|��I�d�$�4f�8_�|���yuq ~
    How i can generated the key pairs in base 64 or binary????
    Thanxs for help me
    Luis Navarro Nu�ez
    Santiago.
    Chile.
    South America.

    I don't use ABA but BouncyCastle
    this could help you :
    try
    java.security.Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
    java.security.KeyPairGenerator kg = java.security.KeyPairGenerator.getInstance("RSA","BC");
    java.security.KeyPair kp = kg.generateKeyPair();
    java.security.Key pub = kp.getPublic();
    java.security.Key pri = kp.getPrivate();
    System.out.println("pub: " + pub);
    System.out.println("pri: " + pri);
    byte[] pub_e = pub.getEncoded();
    byte[] pri_e = pri.getEncoded();
    java.io.PrintWriter o;
    java.io.DataInputStream i;
    java.io.File f;
    o = new java.io.PrintWriter(new java.io.FileOutputStream("d:/pub64"));
    o.println(new sun.misc.BASE64Encoder().encode(pub_e));
    o.close();
    o = new java.io.PrintWriter(new java.io.FileOutputStream("d:/pri64"));
    o.println(new sun.misc.BASE64Encoder().encode(pri_e));
    o.close();
    java.io.BufferedReader br = new java.io.BufferedReader(new java.io.FileReader("d:/pub64"));
    StringBuffer keyBase64 = new StringBuffer();
    String line = br.readLine ();
    while(line != null)
    keyBase64.append (line);
    line = br.readLine ();
    byte [] pubBytes = new sun.misc.BASE64Decoder().decodeBuffer(keyBase64.toString ());
    br = new java.io.BufferedReader(new java.io.FileReader("d:/pri64"));
    keyBase64 = new StringBuffer();
    line = br.readLine ();
    while(line != null)
    keyBase64.append (line);
    line = br.readLine ();
    byte [] priBytes = new sun.misc.BASE64Decoder().decodeBuffer(keyBase64.toString ());
    java.security.KeyFactory kf = java.security.KeyFactory.getInstance("RSA","BC");
    java.security.Key pubKey = kf.generatePublic(new java.security.spec.X509EncodedKeySpec(pubBytes));
    System.out.println("pub: " + pubKey);
    java.security.Key priKey = kf.generatePrivate(new java.security.spec.PKCS8EncodedKeySpec(priBytes));
    System.out.println("pri: " + priKey);
    catch(Exception e)
    e.printStackTrace ();
    }

  • Help with dispatching JTable event to underlying components in a cell.

    Hello..
    I have a JTable in which i show a panel with clickable labels.. I found that jTable by default doesnt dispatch or allow mouseevents to be caught by underlying elements..
    i need help with dispatching an event from jTable to a label on a panel in a jTable cell.. below is the code i have come up with after finding help with some websites. but i couldnt not get it right.. my dispatched event seems to go back to the jtable itself ..
    any help or suggestion is appreciated..
    Thanks
    'Harish.
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    import java.util.*;
    import javax.swing.table.*;
    * @author  harish
    public class tableDemo extends javax.swing.JFrame {
        JTable jTable1;
        testpane dummyPane;
        /** Creates new form tableDemo */
        public tableDemo() {
            initComponents();
            //table settings
            String[] columnNames = {"Task", "Action"," "};
            Object[][] data = { };
            DefaultTableModel model = new DefaultTableModel(data, columnNames) {
              // This method returns the Class object of the first
              // cell in specified column in the table model.
            public Class getColumnClass(int mColIndex) {
                int rowIndex = 0;
                Object o = getValueAt(rowIndex, mColIndex);
                if (o == null)
                    return Object.class;
                } else
                    return o.getClass();
            jTable1 = new javax.swing.JTable(model);
            jTable1.addMouseListener(new MouseAdapter(){
              public void mouseClicked(MouseEvent e){
                  System.out.println("Clicked");
                  handleTableMouseEvents(e);
                 //invokeExternalApp("http://www.pixagogo.com");
              public void mouseEntered(MouseEvent e){
                  System.out.println("Entered");
                  //handleTableMouseEvents(e);
              public void mouseExited(MouseEvent e){
                  System.out.println("Exited");
                  //handleTableMouseEvents(e);
            jTable1.setRowHeight(100);
            jTable1.getTableHeader().setReorderingAllowed(false);
            jTable1.setBackground(new java.awt.Color(255, 255, 255));
            jTable1.setGridColor(new Color(250,250,250));
            jTable1.setShowGrid(true);
            jTable1.setShowVerticalLines(true);
            jTable1.setShowHorizontalLines(false);
            jTable1.setFont(new Font("Arial",0,11));
            jTable1.setMaximumSize(new java.awt.Dimension(32767, 32767));
            jTable1.setMinimumSize(new java.awt.Dimension(630, 255));
            jTable1.setPreferredSize(null);
            jTable1.setBackground(new Color(255,255,255));
            int vColIndex=0;
            TableColumn col = jTable1.getColumnModel().getColumn(vColIndex);
            int width = 100;
            col.setPreferredWidth(width);
            //add item to 2nd cell       
            Vector vec = new Vector();
            vec.addElement(null);
            dummyPane = new testpane();
            vec.addElement(dummyPane);
            ((DefaultTableModel)jTable1.getModel()).addRow(vec);
            jTable1.repaint();
            this.getContentPane().add(jTable1);
            jTable1.getColumn("Action").setCellRenderer(
              new MultiRenderer());
        protected void handleTableMouseEvents(MouseEvent e){
            TableColumnModel columnModel = jTable1.getColumnModel();
            int column = columnModel.getColumnIndexAtX(e.getX());
            int row    = e.getY() / jTable1.getRowHeight();
            testpane contentPane = (testpane)(jTable1.getModel().getValueAt(row, column));
            // get the mouse click point relative to the content pane
            Point containerPoint = SwingUtilities.convertPoint(jTable1, e.getPoint(),contentPane);
            if (column==1 && row==0)
            // so the user clicked on the cell that we are bothered about.         
            MouseEvent ev1 = (MouseEvent)SwingUtilities.convertMouseEvent(jTable1, e, contentPane);
            //once clicked on the cell.. we dispatch event to the object in that cell
         jTable1.dispatchEvent(ev1);
        private void initComponents() {
            addWindowListener(new java.awt.event.WindowAdapter() {
                public void windowClosing(java.awt.event.WindowEvent evt) {
                    exitForm(evt);
            java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
            setBounds((screenSize.width-528)/2, (screenSize.height-423)/2, 528, 423);
        /** Exit the Application */
        private void exitForm(java.awt.event.WindowEvent evt) {
            System.exit(0);
         * @param args the command line arguments
        public static void main(String args[]) {
            new tableDemo().show();
        // Variables declaration - do not modify
        // End of variables declaration
        class testpane extends JPanel{
            public testpane(){
            GridBagConstraints gridBagConstraints;
            JPanel testpane = new JPanel(new GridBagLayout());
            testpane.setBackground(Color.CYAN);
            JLabel lblTest = new JLabel("test");
            lblTest.addMouseListener(new MouseAdapter(){
              public void mouseClicked(MouseEvent e){
                  System.out.println("panelClicked");
              public void mouseEntered(MouseEvent e){
                  System.out.println("panelEntered");
              public void mouseExited(MouseEvent e){
                  System.out.println("panelExited");
            gridBagConstraints = new java.awt.GridBagConstraints();
            gridBagConstraints.gridx = 0;
            gridBagConstraints.gridy = 0;
            gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
            testpane.add(lblTest,gridBagConstraints);
            this.add(testpane);
    class MultiRenderer extends DefaultTableCellRenderer {
      JCheckBox checkBox = new JCheckBox();
      public Component getTableCellRendererComponent(
                         JTable table, Object value,
                         boolean isSelected, boolean hasFocus,
                         int row, int column) {
        if (value instanceof Boolean) {                    // Boolean
          checkBox.setSelected(((Boolean)value).booleanValue());
          checkBox.setHorizontalAlignment(JLabel.CENTER);
          return checkBox;
        String str = (value == null) ? "" : value.toString();
        return super.getTableCellRendererComponent(
             table,str,isSelected,hasFocus,row,column);
        return (testpane)value;
    class MultiEditor implements TableCellEditor {
      public MultiEditor() {
      public boolean isCellEditable(EventObject anEvent) {return false;}
      public boolean stopCellEditing() {return true;}
      public Object getCellEditorValue() {return null;} 
      public void cancelCellEditing() {}
      public boolean shouldSelectCell(EventObject anEvent) {return false;}
      public Component getTableCellEditorComponent(JTable table, Object value,
                  boolean isSelected, int row, int column) {
        if (value instanceof testpane) {                       // ComboString
          System.out.println("yes instance");
        return null;
      public void addCellEditorListener(javax.swing.event.CellEditorListener l) {
      public void removeCellEditorListener(javax.swing.event.CellEditorListener l) {
    }

    any help on this.. anybody. ?

  • Help with understanding initial admin account vs. directory admin

    Hello,
    I am hoping someone can help me understand the initial admin account created when I was first configuring my server, and the directory admin.
    I have setup an advanced server, and when I was going through the initial setup I created an account that for this discussion I'll call "admin." Once the initial setup was finished I started using Workgroup manager to create accounts. I was informed that I should create a different directory admin so I did and for this discussion we'll call that account "diradmin."
    I am curious why the initial account of admin does not show up in workgroup manager, and why it does not show up as an option in Server Admin to assign permissions.
    Is this making any sense?
    Any explanation is greatly appreciated.
    Thank you,
    Scott

    Hi
    Presumably you used the Server Setup Assistant to configure Services prior to bringing the Server online?
    Not a good idea really. When choosing Advanced after the Server Software has been installed don't enable/configure any service apart from Remote Desktop. Once the Server setup is complete run all available updates. Once you've done that begin to configure required Services using Server Admin. Once you've done that begin to populate your directory nodes with users using WorkGroup Manager.
    The key to understanding the two accounts (a) System Administrator (admin UID 501) and (b) Directory Administrator (diradmin UID 100) is understanding which directory node you want to provide services to. The 'Local' node and the server in general (putting aside the super user 'root') will always be admin. Once you promote the Server from Standalone to OD Master you effectively create another Directory in addition to the Local one. This LDAP Directory can be used for all sorts of things. Principally enabling directory and contact information (amongst other things) to be shared/accessed with users that exist in that node with an enhanced authentication system (Kerberos) not available in the Local node and if the Server is in a Standalone Role. This LDAP Directory is controlled by diradmin. You won't be able to use admin for the LDAP node but you can use diradmin for the server in general - although I would not advise it. You can use root for both nodes - again I would not advise it unless absolutely necessary. Basically use admin to log into the Server and do the day to day stuff and use diradmin for the LDAP. Get into the habit of never having both applications open unless you are going to use them. Once you are done, quit out of them and leave them alone.
    To toggle between the two Directory nodes launch Workgroup Manager and click on the small blue globe below the main set of icons at the top and above the Users/Groups/Machines tabs. You should see at least 4 selections: Local, /LDAPv3/127.0.0.1, Search Policy and Other. If you don't see /LDAPv3/127.0.0.1 select Other and browse for it. If you still don't see it then you effectively don't have an OD Master. This will severely limit the ability of server to provide auot-mounting networked home folders as well as access to iCal Server's features amongst other things.
    Finally if you truly want LDAP and everything that goes with it then your DNS Service - wherever its placed - has to be correctly conigured and tested. This link is for a post that explains how to achieve this simply using the interface:
    http://discussions.apple.com/thread.jspa?threadID=1251475&tstart=45
    Depending on your network environment it might not be appropriate for you? However stick with it as it is a long post and you may find it useful?
    Tony

  • SChannel - Help with Error # 20 (Event ID # 36888)

    Was hoping somebody could help me understand what's causing some SChannel error 20 events I'm seeing in system event logs.
    Running Server 2008 R2 as IIS web servers, have a commercial wildcard SSL certificate in use on multiple sites and we use IIS Crypto's "best practice" settings.
    Majority of our customers, monitoring apps and SSL labs report no issues with HTTPS, however we have one customer with a data-center hosted application which sometimes connects flawlessly, yet other times causes our server to generate fatal alert 20 and
    reset the connection before it even reaches IIS.
    Can't see any pattern to these issues and very little of the discussion online about error 20 seems to fit here as it mostly relates to invalid server certificates, low-level development with SSL or other "consistent HTTPS failure" scenarios while
    ours is more intermittent.
    Reading up on error 20 suggests it should be indicate a "bad record mac", where I'm reading the mac to be a checksum of the SSL message suggesting the message may be incomplete, altered or incorrectly signed -- but not being an expert on either
    schannel or crypto I could be misunderstanding what this means.
    Attempted to find more detail regarding the internal error state value, with very little luck.
    Tried enabling SChannel logging for errors and warnings (3), but that's not provided any more detail before or after this event.
    Right now I'm not entirely sure what's causing the problem which makes it even harder to look at solutions, so if you have any questions or need more detail let me know, will try and keep an eye on this for the next few days.
    - T
    Log Name: System
    Source: Schannel
    Date: [removed]
    Event ID: 36888
    Task Category: None
    Level: Error
    Keywords:
    User: SYSTEM
    Computer: [removed]
    Description:
    The following fatal alert was generated: 20. The internal error state is 960.

    Hi twrty,
    This error can caused by many reasons, typically reason I experienced such as ,Incorrect certificate bind with HTTPS Port 443, enabled Cert Authentication wrong certificate
    was used ,certificate on TMG server is revoked and has not validity, SSL handshake failures between client and server also can cause these events, please check all this above conditions and disable the port 443 related security of your firewall then monitor
    again.
    The similar thread:
    Certificate Services - can't connect using SSL
    https://social.technet.microsoft.com/forums/windowsserver/en-US/091a3222-641b-43a3-ae19-6cc238828950/certificate-services-cant-connect-using-ssl
    Error schannel
    https://social.technet.microsoft.com/Forums/windowsserver/en-US/dc661a87-d78a-4398-96d8-e3659d26f282/error-schannel
    I’m glad to be of help to you!
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Support, contact [email protected]

  • Help with a key that popped off!

    Hi! I was wondering if someone could help me. My dog jumped up on my lap and ripped my apple key off. How do you get these back in?? It is the apple key to the left of the space bar. Thanks!

    Look at the underneath side of the key. Are all the little prongs intact and not bent out of position? If they are bent or broken, you will need to buy a new key.
    You need to put the little ring back in first. (If you already have it in, you need to grab hold of the outside top and bottom and pull them up like pulling up an ironing board. Go on to the next paragraph about attaching the key.) If you don't already have the ring in, you pull it open like you would an ironing board. The front of the circle part should be down, and the outside frame on the front should come up. Take the two tabs that are now down in the back and hook them under the two metal pieces at the back of the hole on the keyboard. Take the flat front part of the circle part that is down and hook it under the metal tab on the keyboard at the front of the hole.
    Next, snap the the key onto the ring part, attaching the front of the key first. Then rock it back and snap on the back part of the key. Pushing in the center of the key, push downward firmly to reseat the key.
    Refer to the photos in this Knowledge Base article as you go, but, hopefully, this will help you understand the photos a little better.
    Good luck!

  • Help with Understanding Regular Expressions

    Hello Folks,
    I need some help in understanding the Regular Expressions.
    -- This returns the Expected string from the Source String. ", Redwood Shores,"
    SELECT
      REGEXP_SUBSTR('500 Oracle Parkway, Redwood Shores, CA,aa',
                    ',[^,]+,', 1, 1) "REGEXPR_SUBSTR"
      FROM DUAL;
    REGEXPR_SUBSTR
    , Redwood Shores,
    However, when the query is changed to find the Second Occurrence of the Pattern, it does not match any. IMV, it should return ", CA,"
    SELECT
      REGEXP_SUBSTR('500 Oracle Parkway, Redwood Shores, CA,aa',
                    ',[^,]+,', 1, *2*) "REGEXPR_SUBSTR"
      FROM DUAL;
    REGEXPR_SUBSTR
    NULLCan somebody help me in understanding Why Second Query not returning ", CA,"?
    I did search this forum and found link to thread "https://forums.oracle.com/forums/thread.jspa?threadID=2400143" for basic tutorials.
    Regards,
    P.

    PurveshK wrote:
    Can somebody help me in understanding Why Second Query not returning ", CA,"?With your query...
    SELECT
      REGEXP_SUBSTR('500 Oracle Parkway, Redwood Shores, CA,aa',
                    ',[^,]+,', 1, *2*) "REGEXPR_SUBSTR"
      FROM DUAL;You are looking for patterns of "comma followed by 1 or more non-comma chrs followed by a comma."
    So, let's manually pattern match that...
    '500 Oracle Parkway, Redwood Shores, CA,aa'
                       ^               ^
                       |               |
                               |
                               |
                      Here to here is the
                      first occurence.So the second occurance will start searching for the same pattern AFTER the first occurence.
    '500 Oracle Parkway, Redwood Shores, CA,aa'
                                        ^
                                        |
    i.e. the search for the second occurence starts heretherefore the first "," from that point is...
    '500 Oracle Parkway, Redwood Shores, CA,aa'
                                           ^
                                           |
                                          hereand there is nothing there matching the pattern you are looking for because it only has the
    "comma follwed by 1 or more non-comma chrs"... but it doesn't have the "followed by a comma"
    ...so there is no second occurence,

  • Help with Unique Key Insert!!!

    I need help with this <<removed by moderator>>
    When i try to do an insert "A" into a DB table, the transaction fills the info on creation mode, but is not doing the same at modification mode.
    Here i send the insert, i don't if the problems comes from sintaxis:
    INSERT zpsprctr_det FROM TABLE it_planif ACCEPTING DUPLICATE KEYS.
    tabal base datos es la zpsprctr_det
    Any ideas please let me know
    Moderator Message: Gun-to-the-head-deadline removed
    Edited by: kishan P on Mar 31, 2011 12:24 PM

    Hi,
    with
    INSERT dbtable FROM TABLE itab ACCEPTING DUPLICATE KEYS.
    you will insert several lines in a database table from an internal table. Duplicate keys are ignored, the 1st entry is written.
    To update them, you should use
    MODIFY dbtable FROM TABLE itab.
    This updates all lines that are existing or inserts all lines that are still missing.  If you have duplicate keys here, the last entry will do the last update.
    Regards,
    Klaus

  • Help with understanding multi-threaded code

    Hi Everyone,
    I am currently reading a book on multi-threading and up until recently I have been able to understand what is going on. The thing is the complexity of the code has just jumped up about two gears without warning. The code is now using inner classes which I am trying to develop an understanding of but I am not finding it easy going, and the book has been lite on explanations. If anybody can help with the following code it will be really appreciated.
    public class SetPriority extends Object
         private static Runnable makeRunnable()
              Runnable r = new Runnable()
                   public void run()
                        for(int i=0; i<5; i++)
                             Thread t = Thread.currentThread();
                             System.out.println("in run() - priority=" + t.getPriority() +
                                          ", name=" + t.getName());
                             try{
                                  Thread.sleep(2000);
                             }catch(InterruptedException x){
                                  //ignore
              return r;
         public static void main(String[] args)
              Thread threadA = new Thread(makeRunnable(), "threadA");
              threadA.setPriority(8);
              threadA.start();
              Thread threadB = new Thread(makeRunnable(), "threadB");
              threadB.setPriority(2);
              threadB.start();
              Runnable r = new Runnable()
                   public void run()
                        Thread threadC = new Thread(makeRunnable(), "threadC");
                        threadC.start();
              Thread threadD = new Thread(r, "threadD");
              threadD.setPriority(7);
              threadD.start();
              try{
                   Thread.sleep(3000);
              }catch(InterruptedException x){
                   //ignore
              threadA.setPriority(3);
              System.out.println("in main() - threadA.getPriority()=" + threadA.getPriority());
    }My greatest challenge is understanding how the makeRunnable() method works. I don't understand how this inner class can be declared static and then multiple "instances" created from it. I know that I have no idea what is going on, please help!!!
    Thanks for your time.
    Regards
    Davo
    P.S.: If you know of any really good references on inner classes, particularly URL resources, please let me know. Thanks again.

    Yikes!! The good news is that you're unlikely to see such convoluted code in real life. But here we go.
    "private static Runnable makeRunnable()" declares a method that returns objects of type Runnable. The fact that the method is declared "static" is pretty irrelevant - I'll describe what that means later.
    The body of the method creates and returns an object of type Runnable. Not much special about it, except that you can give such an object to the constructor of class Thread and as a result the run() method of this Runnable object will be called on a new thread of execution (think - in parallel).
    Now the way it creates this Runnable object is by using the "anonymous inner class" syntax. In effect the method is doing the same as
    public class MyNewClass implements Runnable {
        public void run() {
            // All the same code inside run()
    public class SetPriority {
        private static Runnable makeRunnable() {
            Runnable r = new MyNewClass();
            return r;
        // The rest of the original code
    }Except you don't bother declaring MyNewClass. You're not interested in defining any new method signatures. You just want to create an object that implements Runnable and has certain instructions that you want inside the run() method. Think of the whole approach as shorthand.
    Think about this for a while. In the mean time I'll write up the "static".

  • KeyListener Problems with Directional Key events

    Here's the problem: If I press and hold the up and right directional keys (non-numpad) and then press the left directional key, it doesn't recognize that I pressed left (i.e. "LeftKeyPressed" is not printed). What's up? Is there something I don't know about directional keys that makes them special like this? Thanks.
    Here's the code:
    public void keyPressed(KeyEvent e)
         if(e.getKeyCode() == 37)
                   left = true;
                   System.out.println("LeftKeyPressed");
         if(e.getKeyCode() == 38)
              forward = true;
         if(e.getKeyCode() == 39)
              right = true;
    }

    So you want to hold the up key and the right key down and then also press the left key down, but the left key will not activate when the up and right key are pressed and held down first.
    You might be at the point that you should ask yourself -- why do I want to have a left key event happen when I already have a right and up going on. It's obviously not for directions, you cannot go left and right at the same time.

  • Help with understanding SSL on Netweaver 7.1 and the relevant key stores.

    I am having a great difficulty in understanding how SAP manages and uses SSL certificates in Netweaver 7.1.  More specifically, what the difference is between System, Server, and Client.
    As I can see, there are three PSE key stores I see within STRUST. 
    1. SSL System PSE
    2. SSL Server PSE 
    3. SSL Client PSE
    The System PSE I believe is installed by default and enables the systems to communicate between each other, such as Application Servers and the Central Instance. 
    The Server PSE is the where I store the certificate I generated and had signed by a CA (certificate authority).  It contains a root and intermediate certificate and both have been imported back into the Server PSE store.  When partners connect to me and I agree to accept server only authentication, it is this cert that identifies my server as a trusted server the partner.  Do I need to add the partneru2019s u201Crootu201D or u201Cintermediateu201D certs to my Server PSE in order to allow SSL login?
    The Client PSE is where I store partneru2019s client certificates that I allow to login via u201Cclientu201D authentication.  Without their key installed in this store, they will not be allowed to login via SSL.
    When I wish to make connections to partners, I will take my Server key from the Server PSE, export the key, and send it to the partner so they can import it in their key store.
    Does the above sounds right?  Any clarification would be greatly appreciated.
    Thanks,
    Mike.
    P.S.  I also have questions about how and if certificates are synchronized from the ABAP stack (STRUST) to the JAVA stack (Netweaver Administrator), as keys can be stored in either direction.  If not, does where you store the certificate depend if it is an ABAP or JAVA type connection?

    hi michael,
    <br />
    please be careful - actually, there is NO SSL System PSE.<br />
    There is only a so called "System PSE", which is not at all related to SSL.<br />
    <br />
    The PSEs actually available for SSL as default are:<br />
    <br />
    - the SSL Server PSE (which is a rather complicated construction ... see below) [mandatory]<br />
    - the SSL Client PSE (standard) <br />
    - the SSL Client PSE (anonymous)<br />
    <br />
    Looking at connections using HTTPS/SSL, you always have two communication partners: an entity issuing a request, named the "client", and another entity, to which the request is sent in order to be responded to, named the "server".
    Since an SAP ABAP system can be either client or server in this setup, we have the chance to provide different security environments (= PSE) for these communication roles.<br />
    <br />
    When the SAP system initializes a HTTPS communication, it will make use of one of the SSL Client PSEs. These PSEs mainly serve the purpose of storing the CA certificates that are trusted. Only servers whose server certificate is signed by a CA where the CA root certificate is contained in the SSL Client PSE can be connected to. If the server's certificate is not trusted, the error message "verification of the server's certificate chain faile" will appear in the ICM trace (see note 1094342).<br />
    <br />
    The difference between SSl Client PSEs "standard" and "anonymous" is the actual certificate - the "anonymous" PSE always contains the distinguished name (DN) "CN=anonymous", which can not be used for client authentication. In contrast, the "standard" PSE's DN can be defined freely, so this PSE can be signed by a CA and furthermore used for client authentication.<br />
    <br />
    Now for the SSL Server PSE.<br />
    As mentioned already, the SSL Server PSE can be a complicated thing ... actually, this PSE is only a container for more PSEs. There must be at least the "default" PSE (unfortunately also called "standard"), and there can be up to 1 PSE for each application server.<br />
    In a standard setup, the default PSE is used only for those cases where no application server specific PSE applies. The application server specific PSEs are supposed to be the ones that are actually used by the ICM.<br />
    <br />
    What does "up to 1 per AS" mean? Well - as soon as two SSL Server PSEs use the same DN, these PSEs are no longer distinguished, and will be mapped to the same PSE data (key pair, certificate list). So, if you define the same DN for several application servers, only one PSE is created and used by both application servers.<br />
    <br />
    I hope this (lengthy) epistle anwers more question than opens new ones...<br />
    <br />
    regards,<br />
    sebastian
    Edited by: Sebastian Broll on Apr 8, 2010 8:07 AM (formatting)

  • Help with  On key press and Frame

    Hi everybody,
    I have been trying to make this work but not able to. It would be of great help if u can tell where i am going wrong. Here is my code ( it is prety small) :
    I am trying to draw a random line when i do a keypress on the text field.
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    public class KeyPress extends Frame{
    Label label;
    TextField txtField;
    public static void main(String[] args) {
    KeyPress k = new KeyPress();
    public KeyPress(){
    super("Key Press Event Frame");
    Panel panel = new Panel();
    label = new Label();
    txtField = new TextField(20);
    txtField.addKeyListener(new MyKeyListener());
    add(label, BorderLayout.NORTH);
    panel.add(txtField, BorderLayout.CENTER);
    add(panel, BorderLayout.CENTER);
    addWindowListener(new WindowAdapter(){
    public void windowClosing(WindowEvent we){
    System.exit(0);
    setSize(400,400);
    setVisible(true);
    public class MyKeyListener extends KeyAdapter{
    public void keyPressed(KeyEvent ke){
    char i = ke.getKeyChar();
    String str = Character.toString(i);
    label.setText(str);
    Line2D myLine = new Line2D.Double(5,5,100,100);
    }

    Here's what I come up when I played with your code.
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import java.util.Random;
    public class KeyPress extends Frame {
        TextField txtField;
        Panel panel;
        public static void main(String[] args) {
            KeyPress k = new KeyPress();
        public KeyPress(){
            super("Key Press Event Frame");
            panel = new myCanvass();
            txtField = new TextField(20);
            txtField.addKeyListener(new MyKeyListener());
            panel.setBackground(Color.LIGHT_GRAY);
            add(txtField, BorderLayout.PAGE_END);
            add(panel, BorderLayout.CENTER);
            addWindowListener(new WindowAdapter(){
                public void windowClosing(WindowEvent we){
                    System.exit(0);
            setSize(400,400);
            setVisible(true);
        class myCanvass extends Panel {
            private Graphics2D g2;
            public void paint(Graphics g) {
                drawLine(g);
            private void drawLine(Graphics g) {
                g2 = (Graphics2D) g;
                g2.setColor(Color.RED);
                g2.draw(new Line2D.Double(Math.random() * 150, Math.random() * 150, Math.random() * 200, Math.random() * 200));
        class MyKeyListener extends KeyAdapter{
            public void keyPressed(KeyEvent ke){
                char i = ke.getKeyChar();
                String str = Character.toString(i);
                panel.repaint();
    }

  • Help with understanding script for rotating objects

    Hi all
    would some help me with this, I am trying to understand what part of AS3 script says loop through(create a continues 360 loop of objects) the images from an XML file, does this make any sense.
    in my script I have this
    for(var i:int = 0; i < images.length(); i++)
    is this the part that says loop the images/objects
    this is a little more to the script including the above to maybe understand better?
    private function onXMLComplete(event:Event):void
    // Create an XML Object from loaded data
    var data:XML = new XML(xmlLoader.data);
    // Now we can parse it
    var images:XMLList = data.image;
    for(var i:int = 0; i < images.length(); i++)  <<<<<<<<FROM ABOVE ///        {
    // Get info from XML node
    var imageName:String = images[i].@name;
    var imagePath:String = images[i].@path;
    var titles:String = images[i].@title;
    var texts:String = images[i].@text;
    any help would be great

    hi rob
    ok I found this menu which rotates item around on a 360 wheel trying to see if I can use the same script on my menu,
    link to example: http://art.clubworldgroup.com/menu/R...g_menu_AS3.zip
    I have highlighted in blue what creates the loop of items
    in my menu I do  ot have anything like
    var angleDifference:Number = Math.PI * (360 / NUMBER_OF_ITEMS) / 180;
    which sest up the 360 circle of the item
    //Save the center coordinates of the stage
    var centerX:Number=stage.stageWidth/2;
    var centerY:Number=stage.stageHeight/2;
    //The number of items we will have (feel free to change!)
    var NUMBER_OF_ITEMS:uint=15;
    //Radius of the menu circle (horizontal and vertical)
    var radiusX:Number=200;
    var radiusY:Number=200;
    //Angle difference between the items (in radians)
    var angleDifference:Number = Math.PI * (360 / NUMBER_OF_ITEMS) / 180;
    //How fast a single circle moves (we calculate the speed
    //according to the mouse position later on...)
    var angleSpeed:Number=0;
    //Scaling speed of a single circle
    var scaleSpeed:Number=0.0002;
    //This vector holds all the items
    //(this could also be an array...)
    var itemVector:Vector.<Item>=new Vector.<Item>;
    //This loop creates the items and positions them
    //on the stage
    for (var i:uint = 0; i < NUMBER_OF_ITEMS; i++) {
        //Create a new menu item
        var item:Item = new Item();
        //Get the angle for the item (we space the items evenly)
       var startingAngle:Number=angleDifference*i;
        //Set the x and y coordinates
        item.x=centerX+radiusX*Math.cos(startingAngle);
        item.y=centerY+radiusY*Math.sin(startingAngle);
        //Save the starting angle of the item.
        //(We have declared the Item class to be dymamic. Therefore,
        //we can create new properties dynamically.)
        item.angle=startingAngle;
        //Add an item number to the item's text field
        item.itemText.text=i.toString();
        //Allow no mouse children
        item.mouseChildren=false;
        //Add the item to the vector
        itemVector.push(item);
        //Add the item to the stage
        addChild(item);
    //We use ENTER_FRAME to animate the items
    addEventListener(Event.ENTER_FRAME, enterFrameHandler);
    //This function is called in each frame
    function enterFrameHandler(e:Event):void {
        //Calculate the angle speed according to mouse position
        angleSpeed = (mouseY - centerY) / 5000;
        //Loop through the vector
        for (var i:uint = 0; i < NUMBER_OF_ITEMS; i++) {
            //Save the item to a local variable
            var item:Item=itemVector[i];
            //Update the angle
            item.angle+=angleSpeed;
            //Set the new coordinates
            item.x=centerX+radiusX*Math.sin(item.angle);
            item.y=centerY+radiusY*Math.cos(item.angle);
            //Calculate the vertical distance from centerY to the item
            var dx:Number=centerX-item.x;
            //Scale the item according to vertical distance
            //item.scaleX = (dx / radiusX);
            //If we are above centerY, double the y scale
            if (item.x<centerX) {
                item.scaleX*=1;
            //Set the x scale to be the same as y scale
            item.scaleY=item.scaleX;
            //Adjust the alpha according to y scale
            item.alpha=item.scaleX+1.9;

  • Help with understanding the Home Folder plus User Accounts

    I just got the IMac (replacing an ageing...that is an understatement...Grape iMac from long ago) and this is my first go at the OSX. My previous iMac had OS9.2
    I am having a problem understanding the Home folder and the Users to a point. The concepts are fine, it is the changing of names that is the problem. When I first started the iMac and went through the set-up and finally looked at the file structure, there was the Home Folder with a name, which i guess was pre-entered during set-up since I did not enter it (lets call it JOE). There was also 1 User, JOE with all the iLife folders. Since I did not like the name, i went to the Systems Preferences, into Accounts and found that JOE is an Admin. So, I changed the name to, lets say BILL, who still is an Admin. I also changed some settings and made BILL the auto log account. OK so far I am happy. I go back to the HD and find that now there are 2 users (folders), BILL and JOE, and that the Home Folder is still named JOE butall the iLife files are now under BILL.
    So I went and also renamed the Home Folder to BILL, so everything looks fine. But when I restarted the iMac latter it lost all the settings (mouse, etc.) This is really getting confusing.
    Here is what I want to do (after some reasearch):
    I want to change the Short Name (JOE) but so far I have read that you can not do that. Where did this name come from (basically my first initial and my last name) because I don't want my Home Folder to be named that. I found somewhere that the only way to do that is an Erase and Install. I am willing to do that since I have a backup of all the iLife files on an external disk anyways and I have not put anything new yet.
    Can someone enlighten me as to what would be the best course of action....this Short Name thing is frustrating.
    iMac 20" 2.33MHz   Mac OS X (10.4.9)  

    Welcome To Discussions kapklo!
    First you need to sort out the extra Home folder issue, that was created by changing the Short Names.
    The info in one or more of the articles linked to below, will help you with that.
    Return to Default Desktop, Apparent "Loss" of Home Directory
    My home folder and desktop are different than before
    Recover from renaming your Home folder, authored by Dr Smoke
    Then you can change the Short Name using this Change Short Name The Easy Way.
    Or you could do an Erase & Install, making sure you enter your preferred Short Name, during the setup process.
    ali b

  • Need Help with scope in event handlers in AS 2.0!

    I am trying to integrate an XML loading script into my FLA. I
    got the script from a book (I'm learning this) and it worked fine
    when in a timeline frame (loaded all perfectly well), but when I
    put it into an AS 2.0 class (which I'd been using with hardcoded
    data for testing) all fails miserably. I'm trying to get the loaded
    XML data processed with another class private function when the
    onLoad event comes from loading the XML, but this second
    function never gets called. All just fails silently. PLUS I'm
    trying to store the loaded data into two arrays which are class
    properties so that I can access the data later. They are not
    accessible. If this seems muddled it's only because I've been
    banging my head against this for 2 hours. I've read Moock, and then
    I went to Macromedia's online help -- and you will see in my code
    that I tried to set up an "owner" variable to clarify scope. It
    didn't.
    Basically: how does one handle scope of other class functions
    AND class properties from within an event handler in the class?
    As a very important bonus question: is there a way to set up
    eventListeners and callback functions
    between classes, or is this verboten?
    Please help if you can -- I know it's obvious to you, and
    soon perhaps to me --
    Thanks -- Robert
    (Code follows)

    Thanks -- indeed a crucial call might be missing. I was doing
    this until 3 yesterday morning.
    Would this be the correct sample code to use? :
    http://livedocs.macromedia.com/flash/mx2004/main_7_2/wwhelp/wwhimpl/common/html/wwhelp.htm ?context=Flash_MX_2004&file=00000846.html
    It seems to work (although someone cautions in the page
    comments that it doesn't).
    Part of my trouble in working with AS 2.0 is that I feel I
    shouldn't have to do such complicated things (Delegate classes,
    etc) in order to get simple things done (loading XML files). This
    is not a complaint per se -- rather I feel that I must be missing
    something, that it is my inexperience that is causing me to bend
    through so many hoops: programming "should" be elegant and simple.
    So, any links helpful. Thanks.

Maybe you are looking for

  • Error occured during extraction from APO to BI 7.0

    Hi Experts, I am in the process of extracting data from SCM(APO-Demand Planning) to BI .I have selected the relevant planning area 9ADP01 and given Generate Export DS in APO system and replicated the same in BI.But before scheduling the InfoPackage,w

  • Aluminum keyboard eject button does not work on Windows XP

    I'm wondering if anyone else has the same issue: the eject disk button on my new aluminum keyboard does not work in Windows XP (Boot Camp). As I have a Mac Pro, there is no way of manually opening and closing the tray-loading Superdrive. I can open t

  • No option to save files, content/file type missing from Applications list

    I want to be able to click a link to a file and have the option to Open the file with a specified application. When clicking on the file I want to Open with a specified application, I only get a Save or Cancel option. When I look in Preferences > App

  • Mac Book Air HD mysteriously full of 200 GB of "Other"

    Got the MB Air a few weeks back and now the HD has filled itself up with 200 gigs of mystery junk.  Help!

  • Webservice call from RAD

    Hi, I published a RFC/Webservice in 6.20. I have successfully tested using an XMLSPy tool. Now I asked my friend in WEB APP team who has a RAD(Rational App. Devlopment) to consume my webservice by providing teh WSDL file. HE is getting 'Unable to des