En el siguiente vídeo se muestran todas las variantes del showInputDialog y como podemos utilizarlo. Además se muestra un pequeño error que sale al momento de dar clic a cancelar.
Código
El siguiente código fue escrito dentro del botón "buscar" para más comodidad utilizamos un try-catch para capturar un error de dato nulo y utilizamos un switch para el combo box.try {
switch (cbInputDialog.getSelectedIndex()) {
case 0:
txtValor.setText(showInputDialog("Ingresa un número"));
break;
case 1:
txtValor.setText(showInputDialog(this, "Ingresa un nombre:"));
break;
case 2:
txtValor.setText(showInputDialog("Ingresa un número:", "Pedro"));
break;
case 3:
txtValor.setText(showInputDialog(this, "Ingresa un número:", "Pedro"));
break;
case 4:
txtValor.setText(showInputDialog(this, "Ingresa un valor", "VALORES", JOptionPane.INFORMATION_MESSAGE));
break;
case 5:
txtValor.setText(showInputDialog(this, "Ingresa un cliente", "CLIENTE", JOptionPane.INFORMATION_MESSAGE, new ImageIcon(ShowInputDialogs.class.getResource("clientes.png")), null, "Julieta").toString());
break;
case 6:
txtValor.setText(showInputDialog(this, "Ingresa un cliente", "CLIENTE", JOptionPane.INFORMATION_MESSAGE, new ImageIcon(ShowInputDialogs.class.getResource("clientes.png")), val, "Julieta").toString());
break;
}
} catch (NullPointerException e) {
System.out.println(e.getMessage());
}
Proyecto de GitHub - Descargar
Siguenos en:
Blogger -- http://codefluid.blogspot.mx
Facebook -- https://www.facebook.com/CodeFluid
Twitter -- https://twitter.com/CodeFluid
GitHub -- https://github.com/CodeFluid
Vimeo -- https://vimeo.com/user47266653












0 comentarios:
Publicar un comentario