-
-
Save parzibyte/c5e4e6271084f2539220be259843d160 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void jButtonTraducirActionPerformed(java.awt.event.ActionEvent evt) { | |
String entrada = this.jTextFieldEntrada.getText(); | |
if (entrada.length() <= 0) { | |
JOptionPane.showMessageDialog(null, "No has ingresado nada para traducir"); | |
return; | |
} | |
HashMap<String, String> traducciones = new HashMap<>(); | |
// Lo único que aprendí en mi clase de inglés: | |
traducciones.put("hola", "hello"); | |
traducciones.put("perro", "dog"); | |
traducciones.put("gato", "cat"); | |
traducciones.put("¿Puedo ir al baño?", "May I go to the bathroom?"); | |
// Aquí más traducciones... | |
String traduccion = traducciones.get(entrada); | |
if (traduccion == null) { | |
this.jLabelResultado.setText("No encontrado"); | |
} else { | |
this.jLabelResultado.setText(traduccion); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment