Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package gui;
- import java.awt.BorderLayout;
- import java.awt.FlowLayout;
- import javax.swing.JButton;
- import javax.swing.JDialog;
- import javax.swing.JPanel;
- import javax.swing.border.EmptyBorder;
- import java.awt.Color;
- import javax.swing.JLabel;
- import javax.swing.ImageIcon;
- import java.awt.Font;
- public class VentanaConfirmacion extends JDialog {
- private JLabel lblSuPedidoHa;
- private JLabel lbCodigo;
- private String generarCodigo () {
- String codigo = "";
- String base ="0123456789qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM";
- for (int i = 0; i < 10; i++) {
- int numero = (int) ( Math.random() * base.length());
- codigo += base.substring(numero, numero + 1);
- }
- return codigo;
- }
- /**
- * Launch the application.
- */
- public static void main(String[] args) {
- try {
- VentanaConfirmacion dialog = new VentanaConfirmacion();
- dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
- dialog.setVisible(true);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- /**
- * Create the dialog.
- */
- public VentanaConfirmacion() {
- setResizable(false);
- setTitle("Confirmaci\u00F3n de la compra");
- getContentPane().setBackground(Color.WHITE);
- setBounds(100, 100, 450, 300);
- getContentPane().setLayout(null);
- {
- JLabel lbOk = new JLabel("");
- lbOk.setIcon(new ImageIcon(VentanaConfirmacion.class.getResource("/img/ok.png")));
- lbOk.setBounds(78, 82, 50, 50);
- getContentPane().add(lbOk);
- }
- {
- JButton btnFinalizar = new JButton("Finalizar");
- btnFinalizar.setBounds(335, 228, 89, 23);
- getContentPane().add(btnFinalizar);
- }
- getContentPane().add(getLblSuPedidoHa());
- getContentPane().add(getLbCodigo());
- }
- private JLabel getLblSuPedidoHa() {
- if (lblSuPedidoHa == null) {
- lblSuPedidoHa = new JLabel("Su pedido ha sido realizado");
- lblSuPedidoHa.setFont(new Font("Tahoma", Font.BOLD, 19));
- lblSuPedidoHa.setBounds(155, 90, 269, 42);
- }
- return lblSuPedidoHa;
- }
- private JLabel getLbCodigo() {
- if (lbCodigo == null) {
- lbCodigo = new JLabel("");
- lbCodigo.setBounds(155, 143, 89, 14);
- lbCodigo.setText(generarCodigo());
- }
- return lbCodigo;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement