Problema em organizar palavras

problema é o seguinte caso a pessoa digite abc ele escreve abc mais quando a pessoa inverte as letras exemplo cba ele escreve abc ou seja sempre pega a função que está em cima se eu digito test ele escreve tset alguém sabe se tem como usar algum temporizador para que as letras saião de acordo com o digitado código:

if (e.getMessage().toLowerCase().contains(“a”)) {

                    a(); //chama a função
                    
                    

                }

                if (e.getMessage().toLowerCase().contains("b")) {

                    b();
                    
                    
                }
                if (e.getMessage().toLowerCase().contains("c")) {

                    c();
                    
                }

function a() {
try {

        Robot robot = new Robot();
        
       
        robot.keyPress(KeyEvent.VK_A);
        robot.keyRelease(KeyEvent.VK_A);

    } catch (AWTException e) {
    }
    return null;

}

function b() {
    try {
       
        Robot robot = new Robot();
       
        robot.keyPress(KeyEvent.VK_B);
        robot.keyRelease(KeyEvent.VK_B);

    } catch (AWTException e) {
    }
    return null;

}

function c() {
    try {
        
        Robot robot = new Robot();
        
        robot.keyPress(KeyEvent.VK_C);
        robot.keyRelease(KeyEvent.VK_C);

    } catch (AWTException e) {
    }
    return null;

}