[code]import java.awt.event.*;
import java.util.*;
import java.awt.*;
import javax.swing.event.*;
import javax.swing.*;
public class yeah extends JFrame{
Random r= new Random();
int n1= r.nextInt(999);
int n2=r.nextInt(9999);
int n3=r.nextInt(99999);
int n4=r.nextInt(999999);
private JTextField item1;
private JButton item2;
private JButton item3;
private JButton item4;
private JButton item5;
public yeah(){
super("trying Password Generator");
setLayout(new FlowLayout());
item1 = new JTextField(10);
item2 = new JButton("3 digits ");
item3 = new JButton("4 digts");
item4 = new JButton("5 digits");
item5 = new JButton("6 digits");
getContentPane().setBackground(Color.YELLOW);
add(item1);
add(item2);
add(item3);
add(item4);
add(item5);
thehandler handler =new thehandler();
item2.addActionListener(handler);
item3.addActionListener(handler);
item4.addActionListener(handler);
item5.addActionListener(handler);
}
public class thehandler implements ActionListener{
public void actionPerformed(ActionEvent event){
String s=" ";
if(event.getSource()==item2){
s =String.format("%d", n1);
item1.setText(s);
}else
if(event.getSource()==item3){
s =String.format("%d", n2);
item1.setText(s);
}else
if(event.getSource()==item4){
s =String.format("%d", n3);
item1.setText(s);
}
else
if(event.getSource()==item5){
s =String.format("%d",n4);
item1.setText(s);
}
else
item1.setText(" ");
}
}
}
main class --->
import javax.swing.*;
class yeah{
public static void main(String[] args){
yeah f= new yeah();
f.setVisible(true);
f.setSize(350,250);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
</code>
helo friends ! well iam just a noob in java , and iam done with some basics.
wen my father was alive he told me always think bigger and bigger , that's what i try to do ,
iam trying to make a random pasword generator , though i have not made it and donn know if i even cud make it some day but i wil try for sure
copy this code , make two classes , on netbeans or eclipse and run it
my querry--> 1st -> how can we generate some random strings so dat i can put it on ??
2nd--> how can i repeat this process ?? of generating , as it shuts down wen click once , i think i have to put loop on it ??
some1 plz help me out and dont b harsh on me , i hve just started
sorry after main class --->
its not class "yeah" replace that with something else , obviously dats my subclass ,
sorry for dat
import java.util.*;
import java.awt.*;
import javax.swing.event.*;
import javax.swing.*;
public class yeah extends JFrame{
Random r= new Random();
int n1= r.nextInt(999);
int n2=r.nextInt(9999);
int n3=r.nextInt(99999);
int n4=r.nextInt(999999);
private JTextField item1;
private JButton item2;
private JButton item3;
private JButton item4;
private JButton item5;
public yeah(){
super("trying Password Generator");
setLayout(new FlowLayout());
item1 = new JTextField(10);
item2 = new JButton("3 digits ");
item3 = new JButton("4 digts");
item4 = new JButton("5 digits");
item5 = new JButton("6 digits");
getContentPane().setBackground(Color.YELLOW);
add(item1);
add(item2);
add(item3);
add(item4);
add(item5);
thehandler handler =new thehandler();
item2.addActionListener(handler);
item3.addActionListener(handler);
item4.addActionListener(handler);
item5.addActionListener(handler);
}
public class thehandler implements ActionListener{
public void actionPerformed(ActionEvent event){
String s=" ";
if(event.getSource()==item2){
s =String.format("%d", n1);
item1.setText(s);
}else
if(event.getSource()==item3){
s =String.format("%d", n2);
item1.setText(s);
}else
if(event.getSource()==item4){
s =String.format("%d", n3);
item1.setText(s);
}
else
if(event.getSource()==item5){
s =String.format("%d",n4);
item1.setText(s);
}
else
item1.setText(" ");
}
}
}
main class --->
import javax.swing.*;
class yeah{
public static void main(String[] args){
yeah f= new yeah();
f.setVisible(true);
f.setSize(350,250);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
</code>
helo friends ! well iam just a noob in java , and iam done with some basics.
wen my father was alive he told me always think bigger and bigger , that's what i try to do ,
iam trying to make a random pasword generator , though i have not made it and donn know if i even cud make it some day but i wil try for sure
copy this code , make two classes , on netbeans or eclipse and run it
my querry--> 1st -> how can we generate some random strings so dat i can put it on ??
2nd--> how can i repeat this process ?? of generating , as it shuts down wen click once , i think i have to put loop on it ??
some1 plz help me out and dont b harsh on me , i hve just started
sorry after main class --->
its not class "yeah" replace that with something else , obviously dats my subclass ,
sorry for dat