ConfigDialog.java 文件源码

java
阅读 31 收藏 0 点赞 0 评论 0

项目:xdman 作者:
Credential getCredential(String shost, String suser, String spass) {
    JTextField host = new JTextField(shost);
    JTextField user = new JTextField(suser);
    JPasswordField pass = new JPasswordField(spass);
    Object[] obj = new Object[6];
    obj[0] = getString("HOST");
    obj[1] = host;
    obj[2] = getString("USER_NAME");
    obj[3] = user;
    obj[4] = getString("PASSWORD");
    obj[5] = pass;

    while (JOptionPane.showOptionDialog(null, obj, getString("LBL_CR"),
            JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE,
            null, null, null) == JOptionPane.OK_OPTION) {
        if (host.getText() == null || host.getText().length() < 1) {
            JOptionPane.showMessageDialog(null, getString("LBL_HOST"));
            continue;
        }
        if (user.getText() == null || user.getText().length() < 1) {
            JOptionPane.showMessageDialog(null, getString("LBL_USER"));
            continue;
        }

        Credential c = new Credential();
        c.host = host.getText();
        c.user = user.getText();
        c.pass = pass.getPassword().length > 0 ? new String(pass
                .getPassword()) : null;
        return c;
    }
    return null;
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号