Advertisement
Guest User

Untitled

a guest
Oct 1st, 2015
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.17 KB | None | 0 0
  1. package gui;
  2.  
  3. import java.awt.BorderLayout;
  4. import java.awt.FlowLayout;
  5.  
  6. import javax.swing.JButton;
  7. import javax.swing.JDialog;
  8. import javax.swing.JPanel;
  9. import javax.swing.border.EmptyBorder;
  10. import java.awt.Color;
  11. import javax.swing.JLabel;
  12. import javax.swing.ImageIcon;
  13. import java.awt.Font;
  14.  
  15. public class VentanaConfirmacion extends JDialog {
  16. private JLabel lblSuPedidoHa;
  17. private JLabel lbCodigo;
  18.  
  19. private String generarCodigo () {
  20. String codigo = "";
  21. String base ="0123456789qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM";
  22.  
  23. for (int i = 0; i < 10; i++) {
  24. int numero = (int) ( Math.random() * base.length());
  25. codigo += base.substring(numero, numero + 1);
  26. }
  27.  
  28. return codigo;
  29. }
  30.  
  31. /**
  32. * Launch the application.
  33. */
  34. public static void main(String[] args) {
  35. try {
  36. VentanaConfirmacion dialog = new VentanaConfirmacion();
  37. dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
  38. dialog.setVisible(true);
  39. } catch (Exception e) {
  40. e.printStackTrace();
  41. }
  42. }
  43.  
  44. /**
  45. * Create the dialog.
  46. */
  47. public VentanaConfirmacion() {
  48. setResizable(false);
  49. setTitle("Confirmaci\u00F3n de la compra");
  50. getContentPane().setBackground(Color.WHITE);
  51. setBounds(100, 100, 450, 300);
  52. getContentPane().setLayout(null);
  53. {
  54. JLabel lbOk = new JLabel("");
  55. lbOk.setIcon(new ImageIcon(VentanaConfirmacion.class.getResource("/img/ok.png")));
  56. lbOk.setBounds(78, 82, 50, 50);
  57. getContentPane().add(lbOk);
  58. }
  59. {
  60. JButton btnFinalizar = new JButton("Finalizar");
  61. btnFinalizar.setBounds(335, 228, 89, 23);
  62. getContentPane().add(btnFinalizar);
  63. }
  64. getContentPane().add(getLblSuPedidoHa());
  65. getContentPane().add(getLbCodigo());
  66. }
  67. private JLabel getLblSuPedidoHa() {
  68. if (lblSuPedidoHa == null) {
  69. lblSuPedidoHa = new JLabel("Su pedido ha sido realizado");
  70. lblSuPedidoHa.setFont(new Font("Tahoma", Font.BOLD, 19));
  71. lblSuPedidoHa.setBounds(155, 90, 269, 42);
  72. }
  73. return lblSuPedidoHa;
  74. }
  75. private JLabel getLbCodigo() {
  76. if (lbCodigo == null) {
  77. lbCodigo = new JLabel("");
  78. lbCodigo.setBounds(155, 143, 89, 14);
  79. lbCodigo.setText(generarCodigo());
  80. }
  81. return lbCodigo;
  82. }
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement