Java Code Examples for org.eclipse.swt.widgets.Text.setEchoChar()

The following are Jave code examples for showing how to use setEchoChar() of the org.eclipse.swt.widgets.Text class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: BiglyBT   File: PasswordParameter.java   View Source Code Vote up 4 votes
public
 PasswordParameter(
 	Composite 		composite,
final String 	name,
final int		encoding )
 {
 	super(name);
   this.name = name;
   inputField = new Text(composite, SWT.BORDER);
   inputField.setEchoChar('*');
   byte[] value = COConfigurationManager.getByteParameter(name, "".getBytes());
   if(value.length > 0)
     inputField.setText("***");
   inputField.addListener(SWT.Modify, new Listener() {
     @Override
     public void handleEvent(Event event) {
       try{
         String	password_string = inputField.getText();

         byte[] password = password_string.getBytes();
         byte[] encoded;
         if(password.length > 0 ){
       	  if ( encoding == com.biglybt.pif.ui.config.PasswordParameter.ET_PLAIN ){

       		 encoded = password;

       	  }else if ( encoding == com.biglybt.pif.ui.config.PasswordParameter.ET_SHA1 ){

      	         SHA1Hasher hasher = new SHA1Hasher();

      	         encoded = hasher.calculateHash(password);

       	  }else{

       		  	// newly added, might as well go for UTF-8

       		 encoded = MessageDigest.getInstance( "md5").digest( password_string.getBytes( "UTF-8" ));
       	  }
         }else{
           encoded = password;
         }

         COConfigurationManager.setParameter(name, encoded);
       } catch(Exception e) {
       	Debug.printStackTrace( e );
       }
     }
   });
 }