Help me c n edit the password Genarator code !! EMERGENCY
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class passGen implements ActionListener
{
private JFrame f;
private JRadioButton r1,r2,r3,r4;
private JLabel lblLength;
private JTextField txt,txtLength;
private JButton gen,exit;
private JPanel p1,p2,p3,p4;
public passGen()
{
f = new JFrame("Password Generator");
gen = new JButton("generate");
exit = new JButton("exit");
txt = new JTextField(10);
lblLength = new JLabel("Enter length of password:");
txtLength = new JTextField(10);
r1 = new JRadioButton("UpperCase");
r2 = new JRadioButton("LowerCase");
r3 = new JRadioButton("Digits");
r4 = new JRadioButton("Special characters");
gen.addActionListener(this);
exit.addActionListener(this);
f.getContentPane().setLayout(new GridLayout (4,1,10,10));
p1 = new JPanel();
p1.setLayout(new GridLayout(1,4));
p1.add(r1);
p1.add(r2);
p1.add(r3);
p1.add(r4);
f.getContentPane().add(p1);
p4 = new JPanel();
p4.setLayout(new GridLayout(1,2,10,10));
p4.add(lblLength);
p4.add(txtLength);
f.getContentPane().add(p4);
p2 = new JPanel();
p2.setLayout(new GridLayout(1,1));
p2.add(txt);
f.getContentPane().add(p2);
p3 = new JPanel();
p3.setLayout(new FlowLayout());
p3.add(gen);
p3.add(exit);
f.getContentPane().add(p3);
f.setSize(400,400);
f.setVisible(true);
}
public static int MIN_LENGTH = 0;
protected static java. util.Random r = new java.util.Random();
protected static char[] goodChar = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H','I', 'J', 'K',
'M', 'N', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' };
protected static char [] LowChar = {'a','b','c','d','e','f','g','h','i','j','k','l',' m','n','o','p','q','r','s','t','u','v','w','x','y' ,'z' };
protected static char [] numberChar = {'1','2','3','4','5','6','7','8','9','0'};
protected static char [] symchar = {'!','@','#','$','%','^','&','*','(',')'};
protected static char [] UpLowChar = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H','I', 'J', 'K',
'M', 'N', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z','a','b','c','d','e','f','g','h','i','j','k','l ','m','n','o','p','q','r','s','t','u','v','w','x', 'y','z' };
protected static char [] UpLowDigChar = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H','I', 'J', 'K',
'M', 'N', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z','a','b','c','d','e','f','g','h','i','j','k','l ','m','n','o','p','q','r','s','t','u','v','w','x', 'y','z','1','2','3','4','5','6','7','8','9','0'};
protected static char [] UpLowDigSymChar = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H','I', 'J', 'K',
'M', 'N', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z','a','b','c','d','e','f','g','h','i','j','k','l ','m','n','o','p','q','r','s','t','u','v','w','x', 'y','z','1','2','3','4','5','6','7','8','9','0','! ','@','#','$','%','^','&','*','(',')'};
public static String getNext()
{ StringBuffer sb = new StringBuffer();
for(int i =0; i < MIN_LENGTH; i++)
{
sb.append(goodChar[r.nextInt(goodChar.length)]);
}
return sb.toString();
}
public static String getLow()
{
StringBuffer ab = new StringBuffer();
for(int i =0; i<MIN_LENGTH; i++)
{ ab.append(LowChar [r.nextInt(LowChar.length)]);
}
return ab.toString();
}
public static String getNum()
{
StringBuffer cd = new StringBuffer();
for(int i=0; i<MIN_LENGTH ; i++)
{
cd.append(numberChar [r.nextInt(numberChar.length)]);
}
return cd.toString();
}
public static String getSym()
{
StringBuffer ef = new StringBuffer();
for (int i = 0; i<MIN_LENGTH; i++ )
{ef.append(symchar [r.nextInt(symchar.length)]);
}
return ef.toString();
}
public static String getUpLow()
{
StringBuffer gh = new StringBuffer();
for(int i=0; i<MIN_LENGTH; i++)
{ gh.append(UpLowChar [r.nextInt(UpLowChar.length)]);}
return gh.toString();
}
public static String getUpLowDig()
{
StringBuffer ij = new StringBuffer();
for(int i=0; i<MIN_LENGTH; i++)
{ij.append(UpLowDigChar [r.nextInt(UpLowDigChar.length)]);}
return ij.toString();
}
public static String getUpLowDigSym()
{
StringBuffer kl = new StringBuffer();
for(int i =0; i<MIN_LENGTH; i++)
{kl.append(UpLowDigSymChar [r.nextInt(UpLowDigSymChar.length)]);}
return kl.toString();
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource() == gen)
{
int length;
length = Integer.parseInt(txtLength.getText());
MIN_LENGTH = length;
if(r1.isSelected())
{
txt.setText(passGen.getNext());
}
else if(r2.isSelected())
{
txt.setText(passGen.getLow());
}
else if (r3.isSelected())
{
txt.setText(passGen.getNum());
}
else if (r4.isSelected())
{
txt.setText(passGen.getSym());
}
if(r1.isSelected() && r2.isSelected())
{
txt.setText(passGen.getUpLow());
}
if(r1.isSelected() && r2.isSelected() && r3.isSelected())
{
txt.setText(passGen.getUpLowDig());
}
if(r1.isSelected() && r2.isSelected() && r3.isSelected() && r4.isSelected())
{
txt.setText(passGen.getUpLowDigSym());
}
}
else
{
System.exit(0);
}
}
public static void main( String args[])
{
passGen app = new passGen();
}
}
++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++
problem
1. upper case n lower case cant mix wit symbol and digits.
2. if i wan create a textfiled let user key in the special symbol and add on the symbol to the genaraotor for generate.
anyone help me pls..reli EMERGENCY..tat is my final project..i m stucking..pls help me..thx alot..