PasswordCallback isEchoOn - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for PasswordCallback isEchoOn method.

This code example shows how to use the following methods:getPrompt, isEchoOn
        } catch (Exception e) {
            fail("Unexpected exception: " + e);
        } 
 
        try { 
            PasswordCallback pc = new PasswordCallback(prompt, false);
            assertNotNull("Null object returned", pc);
            assertEquals(prompt, pc.getPrompt());
            assertEquals(false, pc.isEchoOn());
        } catch (Exception e) {
            fail("Unexpected exception: " + e);
        } 
 
        try { 
            PasswordCallback pc = new PasswordCallback(null, true);
            fail("IllegalArgumentException wasn't thrown");
        } catch (IllegalArgumentException npe) {
        } 
 
        try { 
6
CodeRank
This code example shows how to use the following methods:clearPassword, getPassword, getPrompt, isEchoOn, setPassword
public class PasswordCallbackTest extends TestCase {
 
    PasswordCallback pc;
 
    public final void testPasswordCallback() { 
        pc = new PasswordCallback("prompt", true);
        assertEquals("prompt", pc.getPrompt());
        assertTrue(pc.isEchoOn());
        pc.setPassword(null);
        pc.clearPassword();
        assertNull(pc.getPassword());
        char[] pwd = {'a','b','c'};
        pc.setPassword(pwd);
        assertEquals(new String(pwd), new String(pc.getPassword()));
        pc.clearPassword();
        assertEquals(pwd.length, pc.getPassword().length);
        assertFalse(new String(pwd).equals(pc.getPassword()));
        char[] p = new char[5];
        pc.setPassword(p);
        pc.clearPassword();

7
CodeRank
This code example shows how to use the following methods:getPrompt, isEchoOn, setPassword
 
  protected synchronized void handlePassword(PasswordCallback c)
  { 
    Frame ownerFrame = new Frame();
    Dialog dialog = new Dialog(ownerFrame);
    dialog.setTitle(c.getPrompt());
    dialog.setLayout(new GridLayout(3, 1));
    Label label = new Label(c.getPrompt());
    TextField input = new TextField();
    if (!c.isEchoOn())
      { 
        input.setEchoChar('*');
      } 
    Panel buttons = new Panel();
    Button ok = new Button(messages.getString("callback.ok"));
    ok.setActionCommand(ACTION_OK);
    ok.addActionListener(this);
    Button cancel = new Button(messages.getString("callback.cancel"));
    cancel.setActionCommand(ACTION_CANCEL);
    cancel.addActionListener(this);

5
CodeRank
This code example shows how to use the following methods:getPrompt, isEchoOn
        } catch (Exception e) {
            fail("Unexpected exception: " + e);
        } 
 
        try { 
            PasswordCallback pc = new PasswordCallback(prompt, false);
            assertNotNull("Null object returned", pc);
            assertEquals(prompt, pc.getPrompt());
            assertEquals(false, pc.isEchoOn());
        } catch (Exception e) {
            fail("Unexpected exception: " + e);
        } 
 
        try { 
            PasswordCallback pc = new PasswordCallback(null, true);
            fail("IllegalArgumentException wasn't thrown");
        } catch (IllegalArgumentException npe) {
        } 
 
        try { 
5
CodeRank
This code example shows how to use the following methods:getPrompt, isEchoOn, setPassword
 
  protected synchronized void handlePassword(PasswordCallback c)
  { 
    Frame ownerFrame = new Frame();
    Dialog dialog = new Dialog(ownerFrame);
    dialog.setTitle(c.getPrompt());
    dialog.setLayout(new GridLayout(3, 1));
    Label label = new Label(c.getPrompt());
    TextField input = new TextField();
    if (!c.isEchoOn())
      { 
        input.setEchoChar('*');
      } 
    Panel buttons = new Panel();
    Button ok = new Button(messages.getString("callback.ok"));
    ok.setActionCommand(ACTION_OK);
    ok.addActionListener(this);
    Button cancel = new Button(messages.getString("callback.cancel"));
    cancel.setActionCommand(ACTION_CANCEL);
    cancel.addActionListener(this);

4
CodeRank
isEchoOn Method Overview
Return whether the password should be displayed as it is being typed.
See Code Examples for other Java 8 PasswordCallback Methods: