private String generatePassword() {

        int n, v;
        Random generator = new Random();
        StringBuffer password = new StringBuffer();
        int max = Integer.parseInt(pswLength.getText());

        for (int i=0; i<max; i++) {

            n = generator.nextInt(3); // uppercase
            v = generator.nextInt(2); // char, symb, number

            if (btnMixed.isSelected()) {
                if (n == 0)
                    n = generator.nextInt(26) + 65;
                else
                    n = generator.nextInt(26) + 97;
            } else if (btnUpper.isSelected()) {
                n = generator.nextInt(26) + 65;
            } else if (btnLower.isSelected()) {
                n = generator.nextInt(26) + 97;
            }

            if (v == 0) {
                if (btnSpec.isSelected())
                    n = generator.nextInt(15) + 33;
            } else if (v == 1) {
                if (btnNumber.isSelected()) {
                    n = generator.nextInt(10) + 48;
                }
            }

            password.append((char)n);
        }

        return password.toString();
    }