
import javax.swing.JOptionPane;
import javax.swing.JRadioButton;

/*
 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 * Click nbfs://nbhost/SystemFileSystem/Templates/GUIForms/JFrame.java to edit this template
 */

/**
 *
 * @author mateo
 */
public class Main extends javax.swing.JFrame {

    /**
     * Creates new form Main
     */
    public Main() {
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        kolorOczuGroup = new javax.swing.ButtonGroup();
        background = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        numerField = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        imieField = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        nazwiskoField = new javax.swing.JTextField();
        kolorOczuPanel = new javax.swing.JPanel();
        niebieskieButton = new javax.swing.JRadioButton();
        zieloneButton = new javax.swing.JRadioButton();
        piwneButton = new javax.swing.JRadioButton();
        odciskIcon = new javax.swing.JLabel();
        osobaIcon = new javax.swing.JLabel();
        okBtn = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Wprowadzenie danych do paszportu. Wykonal: 0000000000");
        setResizable(false);

        background.setBackground(new java.awt.Color(95, 158, 160));

        jLabel1.setForeground(new java.awt.Color(0, 0, 0));
        jLabel1.setText("Numer");

        numerField.setBackground(new java.awt.Color(240, 255, 255));
        numerField.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                numerFieldFocusLost(evt);
            }
        });
        numerField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                numerFieldActionPerformed(evt);
            }
        });

        jLabel2.setForeground(new java.awt.Color(0, 0, 0));
        jLabel2.setText("Imie");

        imieField.setBackground(new java.awt.Color(240, 255, 255));

        jLabel3.setForeground(new java.awt.Color(0, 0, 0));
        jLabel3.setText("Nazwisko");

        nazwiskoField.setBackground(new java.awt.Color(240, 255, 255));

        kolorOczuPanel.setBackground(new java.awt.Color(95, 158, 160));
        kolorOczuPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(new javax.swing.border.LineBorder(new java.awt.Color(255, 255, 255), 3, true), "Kolor Oczu", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.TOP, new java.awt.Font("Segoe UI", 0, 12), new java.awt.Color(0, 0, 0))); // NOI18N

        kolorOczuGroup.add(niebieskieButton);
        niebieskieButton.setSelected(true);
        niebieskieButton.setText("niebieskie");

        kolorOczuGroup.add(zieloneButton);
        zieloneButton.setText("zielone");

        kolorOczuGroup.add(piwneButton);
        piwneButton.setText("piwne");

        javax.swing.GroupLayout kolorOczuPanelLayout = new javax.swing.GroupLayout(kolorOczuPanel);
        kolorOczuPanel.setLayout(kolorOczuPanelLayout);
        kolorOczuPanelLayout.setHorizontalGroup(
            kolorOczuPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(kolorOczuPanelLayout.createSequentialGroup()
                .addGap(18, 18, 18)
                .addGroup(kolorOczuPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(zieloneButton)
                    .addComponent(piwneButton)
                    .addComponent(niebieskieButton))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        kolorOczuPanelLayout.setVerticalGroup(
            kolorOczuPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(kolorOczuPanelLayout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(niebieskieButton)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(zieloneButton)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(piwneButton)
                .addGap(25, 25, 25))
        );

        odciskIcon.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        odciskIcon.setIcon(new javax.swing.ImageIcon(getClass().getResource("/assets/000-odcisk.jpg"))); // NOI18N
        odciskIcon.setFocusable(false);
        odciskIcon.setPreferredSize(new java.awt.Dimension(150, 180));

        osobaIcon.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        osobaIcon.setIcon(new javax.swing.ImageIcon(getClass().getResource("/assets/000-zdjecie.jpg"))); // NOI18N
        osobaIcon.setText("jLabel4");
        osobaIcon.setAlignmentY(0.0F);
        osobaIcon.setPreferredSize(new java.awt.Dimension(236, 180));

        okBtn.setBackground(new java.awt.Color(240, 255, 255));
        okBtn.setText("OK");
        okBtn.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                okBtnMouseClicked(evt);
            }
        });
        okBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                okBtnActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout backgroundLayout = new javax.swing.GroupLayout(background);
        background.setLayout(backgroundLayout);
        backgroundLayout.setHorizontalGroup(
            backgroundLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(backgroundLayout.createSequentialGroup()
                .addGap(27, 27, 27)
                .addGroup(backgroundLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(kolorOczuPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, backgroundLayout.createSequentialGroup()
                        .addComponent(jLabel3)
                        .addGap(18, 18, 18)
                        .addComponent(nazwiskoField, javax.swing.GroupLayout.PREFERRED_SIZE, 239, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, backgroundLayout.createSequentialGroup()
                        .addComponent(jLabel2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(imieField, javax.swing.GroupLayout.PREFERRED_SIZE, 239, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, backgroundLayout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(numerField, javax.swing.GroupLayout.PREFERRED_SIZE, 239, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGroup(backgroundLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(backgroundLayout.createSequentialGroup()
                        .addGap(28, 28, 28)
                        .addComponent(osobaIcon, javax.swing.GroupLayout.PREFERRED_SIZE, 184, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(odciskIcon, javax.swing.GroupLayout.PREFERRED_SIZE, 167, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(0, 37, Short.MAX_VALUE))
                    .addGroup(backgroundLayout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(okBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 214, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(109, 109, 109))))
        );
        backgroundLayout.setVerticalGroup(
            backgroundLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(backgroundLayout.createSequentialGroup()
                .addGap(48, 48, 48)
                .addGroup(backgroundLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(backgroundLayout.createSequentialGroup()
                        .addGroup(backgroundLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel1)
                            .addComponent(numerField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(backgroundLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel2)
                            .addComponent(imieField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(backgroundLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel3)
                            .addComponent(nazwiskoField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 46, Short.MAX_VALUE)
                        .addComponent(kolorOczuPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(backgroundLayout.createSequentialGroup()
                        .addGroup(backgroundLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(odciskIcon, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(osobaIcon, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(okBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(34, 34, 34))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(background, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(background, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void numerFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_numerFieldActionPerformed
        // TODO add your handling code here:    
        
       
    }//GEN-LAST:event_numerFieldActionPerformed

    private void numerFieldFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_numerFieldFocusLost
        // TODO add your handling code here:
        
        String number = numerField.getText();
        
        try {
            odciskIcon.setIcon(new javax.swing.ImageIcon(getClass().getResource("/assets/"+ number + "-odcisk.jpg")));
            odciskIcon.setVisible(true);
            osobaIcon.setIcon(new javax.swing.ImageIcon(getClass().getResource("/assets/"+ number + "-zdjecie.jpg")));
            osobaIcon.setVisible(true);
        } catch(Exception err) {
            odciskIcon.setVisible(false);
            osobaIcon.setVisible(false);
        }
         
    }//GEN-LAST:event_numerFieldFocusLost

    private void okBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okBtnActionPerformed
        // TODO add your handling code here:
        JOptionPane popup = new JOptionPane();
        String imie = imieField.getText();
        String nazwisko = nazwiskoField.getText();
      
        if(imie.length() <=0 || nazwisko.length() <=0) {
            popup.showMessageDialog(rootPane, "Wprowadz dane");
            
            return;
        }
        
        String kolorOczu = "";
        
        if(piwneButton.isSelected()) {
            kolorOczu = "piwne";
        }
        
        if(niebieskieButton.isSelected()) {
            kolorOczu = "niebieskie";
        }
        
        if(zieloneButton.isSelected()) {
            kolorOczu = "zielone";
        }
        
        popup.showMessageDialog(rootPane, imie + " " + nazwisko + " kolor oczu " + kolorOczu);
        
        return;
    }//GEN-LAST:event_okBtnActionPerformed

    private void okBtnMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_okBtnMouseClicked
        // TODO add your handling code here:
       
    }//GEN-LAST:event_okBtnMouseClicked

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(Main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Main().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPanel background;
    private javax.swing.JTextField imieField;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.ButtonGroup kolorOczuGroup;
    private javax.swing.JPanel kolorOczuPanel;
    private javax.swing.JTextField nazwiskoField;
    private javax.swing.JRadioButton niebieskieButton;
    private javax.swing.JTextField numerField;
    private javax.swing.JLabel odciskIcon;
    private javax.swing.JButton okBtn;
    private javax.swing.JLabel osobaIcon;
    private javax.swing.JRadioButton piwneButton;
    private javax.swing.JRadioButton zieloneButton;
    // End of variables declaration//GEN-END:variables
}
