public String changeKeyboardLayout() {
        String previous = pref.getKeyboardLayout();

        String[] layouts = pref.getExistingKeyboardLayouts();
        // TODO: pass current item name
        ChooseFromExisting dialog = new ChooseFromExisting(layouts);
        dialog.dispose();

        String newLayout = dialog.getChosen();

        // Don't do anything if nothing changed
        if (newLayout == null || newLayout.equals(previous))
            return previous;

        boolean foundFlag = false;
        // Check if new layout is in the list of existing layouts
        for (int i = 0; i < layouts.length; i++) {
            // If found, make the new layout first in list
            if (layouts[i].equals(newLayout)) {
                String tmp = layouts[i];
                layouts[i] = layouts[0];
                layouts[0] = tmp;
                foundFlag = true;
                break;
            }
        }

        // Update list of layouts
        String newLayoutList = "";
        if (foundFlag == false)
            newLayoutList += newLayout + ",";
        for (int i = 0; i < layouts.length - 1; i++)
            newLayoutList += layouts[i] + ",";
        newLayoutList += layouts[layouts.length - 1];

        pref.setExistingKeyboardLayouts(newLayoutList);
        pref.update();

        return newLayout;
    }