Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private JButton vocalA;
- private JButton vocalE;
- private JButton vocalI;
- private JButton vocalO;
- private JButton vocalU;
- vocalA = new JButton("A");
- vocalA.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- // Se ejecuta una acción
- }
- });
- vocalA = new JButton("A");
- vocalA.addActionListener((ActionEvent e) -> {
- // Se ejecuta una acción
- });
- private void asignarVocal(String vocal){
- // Se realiza la acción
- }
- vocalA.addActionListener((ActionEvent e) -> {
- asignarVocal(vocalA.getText());
- });
- private void asignarVocal(String vocal){
- tuFrame.getTuLabel().setText(vocal);
- tuFrame.setVisible(true);
- }
- private void iniciarComponentes(){ // < esto es a modo de ejemplo, no sé como lo hagas en tu clase
- // Declaras tus variables....
- vocalA.addActionListener((ActionEvent e) -> {
- asignarVocal(vocalA.getText());
- });
- vocalE.addActionListener((ActionEvent e) -> {
- asignarVocal(vocalE.getText());
- });
- vocalI.addActionListener((ActionEvent e) -> {
- asignarVocal(vocalI.getText());
- });
- vocalO.addActionListener((ActionEvent e) -> {
- asignarVocal(vocalO.getText());
- });
- vocalU.addActionListener((ActionEvent e) -> {
- asignarVocal(vocalU.getText());
- });
- // Inicias otros componentes...
- }
- private void asignarVocal(String vocal){
- tuFrame.getTuLabel().setText(vocal);
- tuFrame.setVisible(true);
- }
Add Comment
Please, Sign In to add comment