Monday 10 September 2012

JAVA CODE TO GENERATE RANDOM PASSWORD

Posted by Unknown On 05:31 | No comments
public class PasswordGenerator {

static final String AB = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz";
    static Random rnd = new Random();

    public String randomString(int len)
    {
          StringBuilder sb = new StringBuilder(len);
           for( int i = 0; i < len; i++ )
                  sb.append( AB.charAt( rnd.nextInt(AB.length()) ) );
                System.out.println(sb);
           return sb.toString();
    }
    public static void main(String a[]){
        PasswordGenerator obj=new PasswordGenerator();
         String s=obj.randomString(6);
        System.out.println(s);
    }

Radio Button and Button Group in java

Posted by Unknown On 05:31 | No comments
 private javax.swing.JRadioButton female=new javax.swing.JRadioButton();

 private javax.swing.JRadioButton male=new javax.swing.JRadioButton();

 private javax.swing.ButtonGroup sex= new javax.swing.ButtonGroup();

  sex.add(female);

 sex.add(male);

String str;

if(male.isSelected())

str="M";
else if (female.isSelected())

str="F";


str will have the datails of the selected Butto

Blogroll

Blogger templates

About