Guest User

Untitled

a guest
Nov 24th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. private JButton vocalA;
  2. private JButton vocalE;
  3. private JButton vocalI;
  4. private JButton vocalO;
  5. private JButton vocalU;
  6.  
  7. vocalA = new JButton("A");
  8. vocalA.addActionListener(new ActionListener() {
  9. @Override
  10. public void actionPerformed(ActionEvent e) {
  11. // Se ejecuta una acción
  12. }
  13. });
  14.  
  15. vocalA = new JButton("A");
  16. vocalA.addActionListener((ActionEvent e) -> {
  17. // Se ejecuta una acción
  18. });
  19.  
  20. private void asignarVocal(String vocal){
  21. // Se realiza la acción
  22. }
  23.  
  24. vocalA.addActionListener((ActionEvent e) -> {
  25. asignarVocal(vocalA.getText());
  26. });
  27.  
  28. private void asignarVocal(String vocal){
  29. tuFrame.getTuLabel().setText(vocal);
  30. tuFrame.setVisible(true);
  31. }
  32.  
  33. private void iniciarComponentes(){ // < esto es a modo de ejemplo, no sé como lo hagas en tu clase
  34. // Declaras tus variables....
  35.  
  36. vocalA.addActionListener((ActionEvent e) -> {
  37. asignarVocal(vocalA.getText());
  38. });
  39. vocalE.addActionListener((ActionEvent e) -> {
  40. asignarVocal(vocalE.getText());
  41. });
  42. vocalI.addActionListener((ActionEvent e) -> {
  43. asignarVocal(vocalI.getText());
  44. });
  45. vocalO.addActionListener((ActionEvent e) -> {
  46. asignarVocal(vocalO.getText());
  47. });
  48. vocalU.addActionListener((ActionEvent e) -> {
  49. asignarVocal(vocalU.getText());
  50. });
  51.  
  52. // Inicias otros componentes...
  53. }
  54.  
  55. private void asignarVocal(String vocal){
  56. tuFrame.getTuLabel().setText(vocal);
  57. tuFrame.setVisible(true);
  58. }
Add Comment
Please, Sign In to add comment