Académique Documents
Professionnel Documents
Culture Documents
*; public class principal { public static JButton Bsig = new JButton("Generar palabra"); public static JFrame f = new JFrame("AHORCADO"); public static JPasswordField Txt1 = new JPasswordField("");
public static JTextField letras [] = new JTextField [20]; public static ImageIcon icono = new ImageIcon("C:/Users/LAURITHA/Desktop/memoria/ahorcado/1.PNG"); public static JLabel Imagen = new JLabel(icono); public static JButton A = new JButton("A"); public static JButton B = new JButton("B"); public static JButton C = new JButton("C"); public static JButton D = new JButton("D"); public static JButton E = new JButton("E"); public static JButton F = new JButton("F"); public static JButton G = new JButton("G"); public static JButton H = new JButton("H"); public static JButton I = new JButton("I"); public static JButton J = new JButton("J"); public static JButton K = new JButton("K"); public static JButton L = new JButton("L");
public static JButton M = new JButton("M"); public static JButton N = new JButton("N"); public static JButton = new JButton(""); public static JButton O = new JButton("O"); public static JButton P = new JButton("P"); public static JButton Q = new JButton("Q"); public static JButton R = new JButton("R"); public static JButton S = new JButton("S"); public static JButton T = new JButton("T"); public static JButton U = new JButton("U"); public static JButton V = new JButton("V"); public static JButton W = new JButton("W"); public static JButton X = new JButton("X"); public static JButton Y = new JButton("Y"); public static JButton Z = new JButton("Z"); public static char[] letra = new char[30]; public static boolean enter = false; static int cont; public static void main(String[] args) { cont=0; A.setBounds(20,20,45,20);; f.add(A); B.setBounds(75,20,45,20); f.add(B); C.setBounds(130,20,45,20); f.add(C);
D.setBounds(20,50,45,20); f.add(D); E.setBounds(75,50,45,20); f.add(E); f.setBounds(130,50,45,20); f.add(F); G.setBounds(20,80,45,20); f.add(G); H.setBounds(75,80,45,20); f.add(H); I.setBounds(130,80,45,20); f.add(I); J.setBounds(20,110,45,20); f.add(J); K.setBounds(75,110,45,20); f.add(K); L.setBounds(130,110,45,20); f.add(L); M.setBounds(20,140,45,20); f.add(M); N.setBounds(75,140,45,20); f.add(N); .setBounds(130,140,45,20); f.add(); O.setBounds(20,170,45,20); f.add(O);
P.setBounds(75,170,45,20); f.add(P); Q.setBounds(130,170,45,20); f.add(Q); R.setBounds(20,200,45,20); f.add(R); S.setBounds(75,200,45,20); f.add(S); T.setBounds(130,200,45,20); f.add(T); U.setBounds(20,230,45,20); f.add(U); V.setBounds(75,230,45,20); f.add(V); W.setBounds(130,230,45,20); f.add(W); X.setBounds(20,260,45,20); f.add(X); Y.setBounds(75,260,45,20); f.add(Y); Z.setBounds(130,260,45,20); f.add(Z); Imagen.setBounds(180,10,280,322); f.add(Imagen); Bsig.setBounds(10,350,150,40); Txt1.setBounds(10,300,150,40);
f.add(Bsig);
f.add(Txt1); f.setBounds(100,200,500,500); f.setLayout(null); int i =0; for(i=0;i<20;i++){ letras[i]=new JTextField(); letras[i].setBounds(250+(i*20),350,20,20); f.add(letras[i]); letras[i].setVisible(false);//
Bsig.addActionListener(new ActionListener(){
@Override
letras[i].setVisible(true); }
}});
A.addActionListener(new ActionListener(){
}});
A.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) { String t = Txt1.getText(); int i= 0; for (i=0;i<t.length();i++) if (letra [i]=='A')
}});
}});
C.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) { String t = Txt1.getText(); int i= 0; for (i=0;i<t.length();i++) if (letra [i]=='C')
{ letras[i].setText('C'+""); enter =true; } if (enter==true) {C.setEnabled(false);} else {cont+=1; Imagen.setIcon(new ImageIcon("C:/Users/LAURITHA/Desktop/memoria/ahorcado/"+cont+".PNG")); C.setEnabled(false); enter=false;
}}); D.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e) { String t = Txt1.getText(); int i= 0; for (i=0;i<t.length();i++) if (letra [i]=='D')
if (enter==true) {D.setEnabled(false);}// if else {cont+=1; Imagen.setIcon(new ImageIcon("C:/Users/LAURITHA/Desktop/memoria/ahorcado/"+cont+".PNG")); D.setEnabled(false); enter=false; }// action listener
}});
E.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e) { String t = Txt1.getText(); int i= 0; for (i=0;i<t.length();i++) if (letra [i]=='E')
}});
F.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e) { String t = Txt1.getText(); int i= 0; for (i=0;i<t.length();i++) if (letra [i]=='F') { letras[i].setText('F'+""); enter =true;
}});
G.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e) { String t = Txt1.getText(); int i= 0; for (i=0;i<t.length();i++) if (letra [i]=='G') {
letras[i].setText('G'+""); enter =true; } if (enter==true) {G.setEnabled(false);}// if else {cont+=1; Imagen.setIcon(new ImageIcon("C:/Users/LAURITHA/Desktop/memoria/ahorcado/"+cont+".PNG")); G.setEnabled(false); enter=false;
}});
H.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e) { String t = Txt1.getText(); int i= 0; for (i=0;i<t.length();i++) if (letra [i]=='H') { letras[i].setText('H'+""); enter =true; } if (enter==true) {H.setEnabled(false);}// if else {cont+=1; Imagen.setIcon(new ImageIcon("C:/Users/LAURITHA/Desktop/memoria/ahorcado/"+cont+".PNG")); H.setEnabled(false); enter=false; }// action listener
}});
I.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) { String t = Txt1.getText(); int i= 0; for (i=0;i<t.length();i++) if (letra [i]=='I') { letras[i].setText('I'+""); enter =true;
}}); J.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e) { String t = Txt1.getText(); int i= 0; for (i=0;i<t.length();i++)
}});
K.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e) { String t = Txt1.getText(); int i= 0; for (i=0;i<t.length();i++) if (letra [i]=='K')
}});
L.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e) { String t = Txt1.getText(); int i= 0; for (i=0;i<t.length();i++) if (letra [i]=='L') {
}});
M.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e) { String t = Txt1.getText(); int i= 0; for (i=0;i<t.length();i++) if (letra [i]=='M') { letras[i].setText('M'+""); enter =true; } if (enter==true) {M.setEnabled(false);}// if else {cont+=1; Imagen.setIcon(new ImageIcon("C:/Users/LAURITHA/Desktop/memoria/ahorcado/"+cont+".PNG"));
M.setEnabled(false); enter=false;
}});
N.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e) { String t = Txt1.getText(); int i= 0; for (i=0;i<t.length();i++) if (letra [i]=='N') { letras[i].setText('N'+""); enter =true; } if (enter==true) {N.setEnabled(false);}// if else {cont+=1; Imagen.setIcon(new ImageIcon("C:/Users/LAURITHA/Desktop/memoria/ahorcado/"+cont+".PNG")); N.setEnabled(false); enter=false;
}});
.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e) { String t = Txt1.getText(); int i= 0; for (i=0;i<t.length();i++) if (letra [i]=='') { letras[i].setText(''+""); enter =true;
}});
O.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) { String t = Txt1.getText(); int i= 0; for (i=0;i<t.length();i++) if (letra [i]=='O')
enter=false;
}});
}});
Q.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e) { String t = Txt1.getText(); int i= 0; for (i=0;i<t.length();i++)
if (letra [i]=='Q')
}});
R.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e) { String t = Txt1.getText(); int i= 0; for (i=0;i<t.length();i++) if (letra [i]=='R') { letras[i].setText('R'+"");
enter =true;
}});
S.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e) { String t = Txt1.getText(); int i= 0; for (i=0;i<t.length();i++) if (letra [i]=='S')
}});
T.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e) { String t = Txt1.getText(); int i= 0; for (i=0;i<t.length();i++) if (letra [i]=='T')
}});
U.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e) { String t = Txt1.getText(); int i= 0; for (i=0;i<t.length();i++) if (letra [i]=='U')
U.setEnabled(false); enter=false;
}});
V.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e) { String t = Txt1.getText(); int i= 0; for (i=0;i<t.length();i++) if (letra [i]=='V') { letras[i].setText('V'+""); enter =true;
} if (enter==true) {V.setEnabled(false);}// if else {cont+=1; Imagen.setIcon(new ImageIcon("C:/Users/LAURITHA/Desktop/memoria/ahorcado/"+cont+".PNG")); V.setEnabled(false); enter=false; }// action listener
}});
W.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e) { String t = Txt1.getText(); int i= 0; for (i=0;i<t.length();i++) if (letra [i]=='W')
{ letras[i].setText('W'+""); enter =true; } if (enter==true) {W.setEnabled(false);}// if else {cont+=1; Imagen.setIcon(new ImageIcon("C:/Users/LAURITHA/Desktop/memoria/ahorcado/"+cont+".PNG")); W.setEnabled(false); enter=false;
if (enter==true) {X.setEnabled(false);}// if else {cont+=1; Imagen.setIcon(new ImageIcon("C:/Users/LAURITHA/Desktop/memoria/ahorcado/"+cont+".PNG")); X.setEnabled(false); enter=false; }// action listener }});
Y.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e) { String t = Txt1.getText(); int i= 0; for (i=0;i<t.length();i++) if (letra [i]=='Y')
public void actionPerformed(ActionEvent e) { String t = Txt1.getText(); int i= 0; for (i=0;i<t.length();i++) if (letra [i]=='Z')
}}); f.setVisible(true);