← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #189203]: Input password : Is there an hidden input method ?

 

Question #189203 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/189203

    Status: Open => Answered

RaiMan proposed the following answer:
For the solution, you must step down to using Java from the Jython
script level (which is no problem).

Here is a Java code snippet, with password input field:

public static void main(String[] args) {
        JLabel jUserName = new JLabel("User Name");
        JTextField userName = new JTextField();
        JLabel jPassword = new JLabel("Password");
        JTextField password = new JPasswordField();
        Object[] ob = {jUserName, userName, jPassword, password};
        int result = JOptionPane.showConfirmDialog(null, ob, "Please input password for JOptionPane showConfirmDialog", JOptionPane.OK_CANCEL_OPTION);
 
        if (result == JOptionPane.OK_OPTION) {
            String userNameValue = userName.getText();
            String passwordValue = password.getText();
            //Here is some validation code
        }
}

In the Sikuli script you only need to import the relevant Java classes:

e.g. try this:
import javax.swing.JOptionPane as JOptionPane
result = JOptionPane.showConfirmDialog(None, None, 
        "Please input password for JOptionPane showConfirmDialog", 
        JOptionPane.OK_CANCEL_OPTION)

-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.