How do I manipulate Joptionpane.showConfirmDialog Java via keyboard?

Asked

Viewed 55 times

1

I created a PDV system for a customer, only he did not like to use mouse when finishing sale, because it loses a lot of time. So I went after several tutorials and forums, but I couldn’t find anything that could help me with this problem.

This is a part of my code (which is 100% working). Only that I would like to use only the keyboard to choose one of the options (no mouse help):

int resposta =   JOptionPane.showConfirmDialog(this, "Deseja imprimir cupom?", "Confirmar", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);

 if(resposta==JOptionPane.YES_OPTION){
     imprimirCupomTickets(listaModelVendaProdutoTickets, modelVendaTickets);
     int codCli = Integer.parseInt(tfUsuarioID.getText());      
     limparFormulario(); 
     }

 else if(resposta==JOptionPane.NO_OPTION){
 int codCli = Integer.parseInt(tfUsuarioID.getText());      
 limparFormulario();       
 }

 else if(resposta==JOptionPane.CLOSED_OPTION){
 int codCli = Integer.parseInt(tfUsuarioID.getText());      
 limparFormulario();    
 }
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.