package ufradvanced;


import javax.swing.JOptionPane;

public class frmBlockReadWrite extends javax.swing.JInternalFrame {

    public frmBlockReadWrite() {
        initComponents();
    }
    
    
     static final int 
         FUNCT_LIGHT_OK     = 4,
         FUNCT_SOUND_OK     = 0,//4 Tripple sound
         FUNCT_LIGHT_ERROR  = 2,
         FUNCT_SOUND_ERROR  = 0,//2 Long sound
         DL_OK              = 0;
    
    static final byte
         MIFARE_AUTHENT1A   = 0x60,  
         MIFARE_AUTHENT1B   = 0x61,
         MAX_BLOCK_BYTES    = 16;
    
    final static String ANY_DATA           = "You must enter any data !",
                        APPROPRIATE_FORMAT = "You must enter the appropriate format !";
    
    byte[] bBlockDataBuffer                = new byte[MAX_BLOCK_BYTES];
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        btngAUTH1AB = new javax.swing.ButtonGroup();
        pgBlockReadWrite = new javax.swing.JTabbedPane();
        tabBlockRead = new javax.swing.JPanel();
        pnlBlockRead = new javax.swing.JPanel();
        txtBlockAddress = new javax.swing.JTextField();
        btnBlockRead = new javax.swing.JButton();
        chkBRHex = new javax.swing.JCheckBox();
        lblBlockRead = new javax.swing.JLabel();
        lblblockAddress = new javax.swing.JLabel();
        txtBlockRead = new javax.swing.JTextField();
        lblReadData = new javax.swing.JLabel();
        pnlBlockReadAKM1 = new javax.swing.JPanel();
        txtBlockAddressAKM1 = new javax.swing.JTextField();
        btnBlockReadAKM1 = new javax.swing.JButton();
        chkBRHexAKM1 = new javax.swing.JCheckBox();
        lblBlockReadAKM1 = new javax.swing.JLabel();
        lblblockAddressAKM1 = new javax.swing.JLabel();
        txtBlockReadAKM1 = new javax.swing.JTextField();
        lblReadDataAKM1 = new javax.swing.JLabel();
        pnlBlockReadPK = new javax.swing.JPanel();
        txtBlockAddressPK = new javax.swing.JTextField();
        btnBlockReadPK = new javax.swing.JButton();
        chkBRHexPK = new javax.swing.JCheckBox();
        lblBlockReadPK = new javax.swing.JLabel();
        lblblockAddressPK = new javax.swing.JLabel();
        txtBlockReadPK = new javax.swing.JTextField();
        lblReadDataPK = new javax.swing.JLabel();
        pnlBlockReadAKM2 = new javax.swing.JPanel();
        txtBlockAddressAKM2 = new javax.swing.JTextField();
        btnBlockReadAKM2 = new javax.swing.JButton();
        chkBRHexAKM2 = new javax.swing.JCheckBox();
        lblBlockReadAKM2 = new javax.swing.JLabel();
        lblblockAddressAKM2 = new javax.swing.JLabel();
        txtBlockReadAKM2 = new javax.swing.JTextField();
        lblReadDataAKM2 = new javax.swing.JLabel();
        jpnlBlockWrite = new javax.swing.JPanel();
        pnlBlockWrite = new javax.swing.JPanel();
        txtWriteData = new javax.swing.JTextField();
        txtBWBlockAddress = new javax.swing.JTextField();
        btnBlockWrite = new javax.swing.JButton();
        lblBlockWrite = new javax.swing.JLabel();
        lblBWBlockAddress = new javax.swing.JLabel();
        lblWriteData = new javax.swing.JLabel();
        chkBWHex = new javax.swing.JCheckBox();
        pnlBlockWriteAKM1 = new javax.swing.JPanel();
        txtWriteDataAKM1 = new javax.swing.JTextField();
        txtBWBlockAddressAKM1 = new javax.swing.JTextField();
        btnBlockWriteAKM1 = new javax.swing.JButton();
        lblBlockReadAKM3 = new javax.swing.JLabel();
        lblBWBlockAddressAKM1 = new javax.swing.JLabel();
        lblWriteDataAKM1 = new javax.swing.JLabel();
        chkBWHexAKM1 = new javax.swing.JCheckBox();
        pnlBlockWriteAKM2 = new javax.swing.JPanel();
        txtWriteDataAKM2 = new javax.swing.JTextField();
        txtBWBlockAddressAKM2 = new javax.swing.JTextField();
        btnBlockWriteAKM2 = new javax.swing.JButton();
        lblBlockWriteAKM2 = new javax.swing.JLabel();
        lblBWBlockAddressAKM2 = new javax.swing.JLabel();
        lblWriteDataAKM2 = new javax.swing.JLabel();
        chkBWHexAKM2 = new javax.swing.JCheckBox();
        pnlBlockWritePK = new javax.swing.JPanel();
        txtWriteDataPK = new javax.swing.JTextField();
        txtBWBlockAddressPK = new javax.swing.JTextField();
        btnBlockWritePK = new javax.swing.JButton();
        lblBlockWritePK = new javax.swing.JLabel();
        lblBWBlockAddressPK = new javax.swing.JLabel();
        lblWriteDataPK = new javax.swing.JLabel();
        chkBWHexPK = new javax.swing.JCheckBox();
        pnlHeader = new javax.swing.JPanel();
        rbAUTH1A = new javax.swing.JRadioButton();
        rbAUTH1B = new javax.swing.JRadioButton();
        lblKeyIndex = new javax.swing.JLabel();
        cboKeyIndex = new javax.swing.JComboBox();
        jLabel1 = new javax.swing.JLabel();
        lblFunction = new javax.swing.JTextField();
        txtFErrorCode = new javax.swing.JTextField();
        txtFErrorExplain = new javax.swing.JTextField();

        setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        setTitle("Block Read/Write");
        setMaximumSize(new java.awt.Dimension(524, 450));
        setName("frmBlockReadWrite"); // NOI18N
        setPreferredSize(new java.awt.Dimension(555, 380));
        setRequestFocusEnabled(false);
        setVisible(true);
        addInternalFrameListener(new javax.swing.event.InternalFrameListener() {
            public void internalFrameActivated(javax.swing.event.InternalFrameEvent evt) {
                formInternalFrameActivated(evt);
            }
            public void internalFrameClosed(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameClosing(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameDeactivated(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameDeiconified(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameIconified(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameOpened(javax.swing.event.InternalFrameEvent evt) {
            }
        });
        getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        pgBlockReadWrite.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
        pgBlockReadWrite.setFont(new java.awt.Font("Verdana", 1, 11)); // NOI18N

        pnlBlockRead.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

        txtBlockAddress.setFont(new java.awt.Font("Verdana", 1, 12)); // NOI18N
        txtBlockAddress.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        txtBlockAddress.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

        btnBlockRead.setFont(new java.awt.Font("Verdana", 1, 11)); // NOI18N
        btnBlockRead.setText("READ");
        btnBlockRead.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        btnBlockRead.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnBlockReadActionPerformed(evt);
            }
        });

        chkBRHex.setFont(new java.awt.Font("Verdana", 0, 11)); // NOI18N
        chkBRHex.setText("Hex");
        chkBRHex.setVisible(true);
        chkBRHex.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        chkBRHex.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                chkBRHexItemStateChanged(evt);
            }
        });

        lblBlockRead.setBackground(new java.awt.Color(153, 153, 153));
        lblBlockRead.setFont(new java.awt.Font("Verdana", 1, 12)); // NOI18N
        lblBlockRead.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        lblBlockRead.setText("Block Read");
        lblBlockRead.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        lblBlockRead.setOpaque(true);

        lblblockAddress.setFont(new java.awt.Font("Verdana", 0, 11)); // NOI18N
        lblblockAddress.setText("Block Address");

        txtBlockRead.setEditable(false);
        txtBlockRead.setBackground(new java.awt.Color(255, 255, 255));
        txtBlockRead.setFont(new java.awt.Font("Dialog", 0, 11)); // NOI18N
        txtBlockRead.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        txtBlockRead.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

        lblReadData.setFont(new java.awt.Font("Verdana", 0, 11)); // NOI18N
        lblReadData.setText("Read Data");

        javax.swing.GroupLayout pnlBlockReadLayout = new javax.swing.GroupLayout(pnlBlockRead);
        pnlBlockRead.setLayout(pnlBlockReadLayout);
        pnlBlockReadLayout.setHorizontalGroup(
            pnlBlockReadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(lblBlockRead, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(pnlBlockReadLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlBlockReadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pnlBlockReadLayout.createSequentialGroup()
                        .addComponent(lblblockAddress)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(txtBlockAddress, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(btnBlockRead, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(pnlBlockReadLayout.createSequentialGroup()
                        .addComponent(lblReadData)
                        .addGap(124, 124, 124)
                        .addComponent(chkBRHex))
                    .addComponent(txtBlockRead))
                .addContainerGap())
        );
        pnlBlockReadLayout.setVerticalGroup(
            pnlBlockReadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlBlockReadLayout.createSequentialGroup()
                .addComponent(lblBlockRead, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnlBlockReadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnBlockRead, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtBlockAddress, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblblockAddress))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnlBlockReadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(chkBRHex, 0, 0, Short.MAX_VALUE)
                    .addComponent(lblReadData, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(txtBlockRead, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        pnlBlockReadAKM1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

        txtBlockAddressAKM1.setFont(new java.awt.Font("Verdana", 1, 12)); // NOI18N
        txtBlockAddressAKM1.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        txtBlockAddressAKM1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

        btnBlockReadAKM1.setFont(new java.awt.Font("Verdana", 1, 11)); // NOI18N
        btnBlockReadAKM1.setText("READ");
        btnBlockReadAKM1.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        btnBlockReadAKM1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnBlockReadAKM1ActionPerformed(evt);
            }
        });

        chkBRHexAKM1.setFont(new java.awt.Font("Verdana", 0, 11)); // NOI18N
        chkBRHexAKM1.setText("Hex");
        chkBRHexAKM1.setVisible(true);
        chkBRHexAKM1.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        chkBRHexAKM1.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                chkBRHexAKM1ItemStateChanged(evt);
            }
        });

        lblBlockReadAKM1.setBackground(new java.awt.Color(153, 153, 153));
        lblBlockReadAKM1.setFont(new java.awt.Font("Verdana", 1, 12)); // NOI18N
        lblBlockReadAKM1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        lblBlockReadAKM1.setText("BlockRead AKM1");
        lblBlockReadAKM1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        lblBlockReadAKM1.setOpaque(true);

        lblblockAddressAKM1.setFont(new java.awt.Font("Verdana", 0, 11)); // NOI18N
        lblblockAddressAKM1.setText("Block Address");

        txtBlockReadAKM1.setEditable(false);
        txtBlockReadAKM1.setBackground(new java.awt.Color(255, 255, 255));
        txtBlockReadAKM1.setFont(new java.awt.Font("Dialog", 0, 11)); // NOI18N
        txtBlockReadAKM1.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        txtBlockReadAKM1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

        lblReadDataAKM1.setFont(new java.awt.Font("Verdana", 0, 11)); // NOI18N
        lblReadDataAKM1.setText("Read Data");

        javax.swing.GroupLayout pnlBlockReadAKM1Layout = new javax.swing.GroupLayout(pnlBlockReadAKM1);
        pnlBlockReadAKM1.setLayout(pnlBlockReadAKM1Layout);
        pnlBlockReadAKM1Layout.setHorizontalGroup(
            pnlBlockReadAKM1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(lblBlockReadAKM1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(pnlBlockReadAKM1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlBlockReadAKM1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pnlBlockReadAKM1Layout.createSequentialGroup()
                        .addComponent(lblblockAddressAKM1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(txtBlockAddressAKM1, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(10, 10, 10)
                        .addComponent(btnBlockReadAKM1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(pnlBlockReadAKM1Layout.createSequentialGroup()
                        .addComponent(lblReadDataAKM1)
                        .addGap(124, 124, 124)
                        .addComponent(chkBRHexAKM1))
                    .addComponent(txtBlockReadAKM1))
                .addContainerGap())
        );
        pnlBlockReadAKM1Layout.setVerticalGroup(
            pnlBlockReadAKM1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlBlockReadAKM1Layout.createSequentialGroup()
                .addComponent(lblBlockReadAKM1, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnlBlockReadAKM1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnBlockReadAKM1, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtBlockAddressAKM1, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblblockAddressAKM1))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnlBlockReadAKM1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(chkBRHexAKM1, 0, 0, Short.MAX_VALUE)
                    .addComponent(lblReadDataAKM1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(txtBlockReadAKM1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        pnlBlockReadPK.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

        txtBlockAddressPK.setFont(new java.awt.Font("Verdana", 1, 12)); // NOI18N
        txtBlockAddressPK.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        txtBlockAddressPK.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

        btnBlockReadPK.setFont(new java.awt.Font("Verdana", 1, 11)); // NOI18N
        btnBlockReadPK.setText("READ");
        btnBlockReadPK.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        btnBlockReadPK.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnBlockReadPKActionPerformed(evt);
            }
        });

        chkBRHexPK.setFont(new java.awt.Font("Verdana", 0, 11)); // NOI18N
        chkBRHexPK.setText("Hex");
        chkBRHexPK.setVisible(true);;
        chkBRHexPK.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        chkBRHexPK.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                chkBRHexPKItemStateChanged(evt);
            }
        });

        lblBlockReadPK.setBackground(new java.awt.Color(153, 153, 153));
        lblBlockReadPK.setFont(new java.awt.Font("Verdana", 1, 12)); // NOI18N
        lblBlockReadPK.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        lblBlockReadPK.setText("BlockRead PK");
        lblBlockReadPK.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        lblBlockReadPK.setOpaque(true);

        lblblockAddressPK.setFont(new java.awt.Font("Verdana", 0, 11)); // NOI18N
        lblblockAddressPK.setText("Block Address");

        txtBlockReadPK.setEditable(false);
        txtBlockReadPK.setBackground(new java.awt.Color(255, 255, 255));
        txtBlockReadPK.setFont(new java.awt.Font("Dialog", 0, 11)); // NOI18N
        txtBlockReadPK.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        txtBlockReadPK.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

        lblReadDataPK.setFont(new java.awt.Font("Verdana", 0, 11)); // NOI18N
        lblReadDataPK.setText("Read Data");

        javax.swing.GroupLayout pnlBlockReadPKLayout = new javax.swing.GroupLayout(pnlBlockReadPK);
        pnlBlockReadPK.setLayout(pnlBlockReadPKLayout);
        pnlBlockReadPKLayout.setHorizontalGroup(
            pnlBlockReadPKLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(lblBlockReadPK, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(pnlBlockReadPKLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlBlockReadPKLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pnlBlockReadPKLayout.createSequentialGroup()
                        .addComponent(lblblockAddressPK)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(txtBlockAddressPK, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(10, 10, 10)
                        .addComponent(btnBlockReadPK, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(pnlBlockReadPKLayout.createSequentialGroup()
                        .addComponent(lblReadDataPK)
                        .addGap(124, 124, 124)
                        .addComponent(chkBRHexPK))
                    .addComponent(txtBlockReadPK))
                .addContainerGap())
        );
        pnlBlockReadPKLayout.setVerticalGroup(
            pnlBlockReadPKLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlBlockReadPKLayout.createSequentialGroup()
                .addComponent(lblBlockReadPK, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnlBlockReadPKLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnBlockReadPK, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtBlockAddressPK, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblblockAddressPK))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnlBlockReadPKLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(chkBRHexPK, 0, 0, Short.MAX_VALUE)
                    .addComponent(lblReadDataPK, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(txtBlockReadPK, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        pnlBlockReadAKM2.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

        txtBlockAddressAKM2.setFont(new java.awt.Font("Verdana", 1, 12)); // NOI18N
        txtBlockAddressAKM2.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        txtBlockAddressAKM2.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

        btnBlockReadAKM2.setFont(new java.awt.Font("Verdana", 1, 11)); // NOI18N
        btnBlockReadAKM2.setText("READ");
        btnBlockReadAKM2.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        btnBlockReadAKM2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnBlockReadAKM2ActionPerformed(evt);
            }
        });

        chkBRHexAKM2.setFont(new java.awt.Font("Verdana", 0, 11)); // NOI18N
        chkBRHexAKM2.setText("Hex");
        chkBRHexAKM2.setVisible(true);
        chkBRHexAKM2.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        chkBRHexAKM2.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                chkBRHexAKM2ItemStateChanged(evt);
            }
        });

        lblBlockReadAKM2.setBackground(new java.awt.Color(153, 153, 153));
        lblBlockReadAKM2.setFont(new java.awt.Font("Verdana", 1, 12)); // NOI18N
        lblBlockReadAKM2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        lblBlockReadAKM2.setText("BlockRead AKM2");
        lblBlockReadAKM2.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        lblBlockReadAKM2.setOpaque(true);

        lblblockAddressAKM2.setFont(new java.awt.Font("Verdana", 0, 11)); // NOI18N
        lblblockAddressAKM2.setText("Block Address");

        txtBlockReadAKM2.setEditable(false);
        txtBlockReadAKM2.setBackground(new java.awt.Color(255, 255, 255));
        txtBlockReadAKM2.setFont(new java.awt.Font("Dialog", 0, 11)); // NOI18N
        txtBlockReadAKM2.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        txtBlockReadAKM2.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

        lblReadDataAKM2.setFont(new java.awt.Font("Verdana", 0, 11)); // NOI18N
        lblReadDataAKM2.setText("Read Data");

        javax.swing.GroupLayout pnlBlockReadAKM2Layout = new javax.swing.GroupLayout(pnlBlockReadAKM2);
        pnlBlockReadAKM2.setLayout(pnlBlockReadAKM2Layout);
        pnlBlockReadAKM2Layout.setHorizontalGroup(
            pnlBlockReadAKM2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(lblBlockReadAKM2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(pnlBlockReadAKM2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlBlockReadAKM2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pnlBlockReadAKM2Layout.createSequentialGroup()
                        .addComponent(lblblockAddressAKM2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(txtBlockAddressAKM2, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(10, 10, 10)
                        .addComponent(btnBlockReadAKM2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(pnlBlockReadAKM2Layout.createSequentialGroup()
                        .addComponent(lblReadDataAKM2)
                        .addGap(124, 124, 124)
                        .addComponent(chkBRHexAKM2))
                    .addComponent(txtBlockReadAKM2))
                .addContainerGap())
        );
        pnlBlockReadAKM2Layout.setVerticalGroup(
            pnlBlockReadAKM2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlBlockReadAKM2Layout.createSequentialGroup()
                .addComponent(lblBlockReadAKM2, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnlBlockReadAKM2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnBlockReadAKM2, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtBlockAddressAKM2, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblblockAddressAKM2))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnlBlockReadAKM2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(chkBRHexAKM2, 0, 0, Short.MAX_VALUE)
                    .addComponent(lblReadDataAKM2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(txtBlockReadAKM2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        javax.swing.GroupLayout tabBlockReadLayout = new javax.swing.GroupLayout(tabBlockRead);
        tabBlockRead.setLayout(tabBlockReadLayout);
        tabBlockReadLayout.setHorizontalGroup(
            tabBlockReadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(tabBlockReadLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(tabBlockReadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(pnlBlockRead, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(pnlBlockReadAKM2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(tabBlockReadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(pnlBlockReadPK, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(pnlBlockReadAKM1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        tabBlockReadLayout.setVerticalGroup(
            tabBlockReadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(tabBlockReadLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(tabBlockReadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(pnlBlockRead, javax.swing.GroupLayout.PREFERRED_SIZE, 124, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(pnlBlockReadAKM1, javax.swing.GroupLayout.PREFERRED_SIZE, 124, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(tabBlockReadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(pnlBlockReadPK, javax.swing.GroupLayout.PREFERRED_SIZE, 124, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(pnlBlockReadAKM2, javax.swing.GroupLayout.PREFERRED_SIZE, 124, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pgBlockReadWrite.addTab("Block Read", tabBlockRead);

        pnlBlockWrite.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        pnlBlockWrite.setPreferredSize(new java.awt.Dimension(242, 121));

        txtWriteData.setBackground(new java.awt.Color(249, 244, 244));
        txtWriteData.setFont(new java.awt.Font("Verdana", 0, 11)); // NOI18N
        txtWriteData.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        txtWriteData.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

        txtBWBlockAddress.setFont(new java.awt.Font("Verdana", 1, 12)); // NOI18N
        txtBWBlockAddress.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        txtBWBlockAddress.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

        btnBlockWrite.setFont(new java.awt.Font("Verdana", 1, 11)); // NOI18N
        btnBlockWrite.setText("WRITE");
        btnBlockWrite.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        btnBlockWrite.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnBlockWriteActionPerformed(evt);
            }
        });

        lblBlockWrite.setBackground(new java.awt.Color(153, 153, 153));
        lblBlockWrite.setFont(new java.awt.Font("Verdana", 1, 12)); // NOI18N
        lblBlockWrite.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        lblBlockWrite.setText("Block Write");
        lblBlockWrite.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        lblBlockWrite.setOpaque(true);

        lblBWBlockAddress.setFont(new java.awt.Font("Verdana", 0, 11)); // NOI18N
        lblBWBlockAddress.setText("Block Address");

        lblWriteData.setFont(new java.awt.Font("Verdana", 0, 11)); // NOI18N
        lblWriteData.setText("Write Data");

        chkBWHex.setFont(new java.awt.Font("Verdana", 0, 11)); // NOI18N
        chkBWHex.setText("Hex");
        chkBWHex.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));

        javax.swing.GroupLayout pnlBlockWriteLayout = new javax.swing.GroupLayout(pnlBlockWrite);
        pnlBlockWrite.setLayout(pnlBlockWriteLayout);
        pnlBlockWriteLayout.setHorizontalGroup(
            pnlBlockWriteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(lblBlockWrite, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(pnlBlockWriteLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlBlockWriteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pnlBlockWriteLayout.createSequentialGroup()
                        .addComponent(lblBWBlockAddress)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(txtBWBlockAddress, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnBlockWrite, javax.swing.GroupLayout.DEFAULT_SIZE, 93, Short.MAX_VALUE))
                    .addGroup(pnlBlockWriteLayout.createSequentialGroup()
                        .addComponent(lblWriteData)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(chkBWHex))
                    .addComponent(txtWriteData))
                .addContainerGap())
        );
        pnlBlockWriteLayout.setVerticalGroup(
            pnlBlockWriteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlBlockWriteLayout.createSequentialGroup()
                .addComponent(lblBlockWrite, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnlBlockWriteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(lblWriteData, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(chkBWHex, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(txtWriteData, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnlBlockWriteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblBWBlockAddress)
                    .addComponent(txtBWBlockAddress, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnBlockWrite, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        pnlBlockWriteAKM1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        pnlBlockWriteAKM1.setPreferredSize(new java.awt.Dimension(242, 121));

        txtWriteDataAKM1.setBackground(new java.awt.Color(249, 244, 244));
        txtWriteDataAKM1.setFont(new java.awt.Font("Verdana", 0, 11)); // NOI18N
        txtWriteDataAKM1.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        txtWriteDataAKM1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

        txtBWBlockAddressAKM1.setFont(new java.awt.Font("Verdana", 1, 12)); // NOI18N
        txtBWBlockAddressAKM1.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        txtBWBlockAddressAKM1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

        btnBlockWriteAKM1.setFont(new java.awt.Font("Verdana", 1, 11)); // NOI18N
        btnBlockWriteAKM1.setText("WRITE");
        btnBlockWriteAKM1.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        btnBlockWriteAKM1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnBlockWriteAKM1ActionPerformed(evt);
            }
        });

        lblBlockReadAKM3.setBackground(new java.awt.Color(153, 153, 153));
        lblBlockReadAKM3.setFont(new java.awt.Font("Verdana", 1, 12)); // NOI18N
        lblBlockReadAKM3.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        lblBlockReadAKM3.setText("BlockWrite AKM1");
        lblBlockReadAKM3.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        lblBlockReadAKM3.setOpaque(true);

        lblBWBlockAddressAKM1.setFont(new java.awt.Font("Verdana", 0, 11)); // NOI18N
        lblBWBlockAddressAKM1.setText("Block Address");

        lblWriteDataAKM1.setFont(new java.awt.Font("Verdana", 0, 11)); // NOI18N
        lblWriteDataAKM1.setText("Write Data");

        chkBWHexAKM1.setFont(new java.awt.Font("Verdana", 0, 11)); // NOI18N
        chkBWHexAKM1.setText("Hex");
        chkBWHexAKM1.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));

        javax.swing.GroupLayout pnlBlockWriteAKM1Layout = new javax.swing.GroupLayout(pnlBlockWriteAKM1);
        pnlBlockWriteAKM1.setLayout(pnlBlockWriteAKM1Layout);
        pnlBlockWriteAKM1Layout.setHorizontalGroup(
            pnlBlockWriteAKM1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(lblBlockReadAKM3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(pnlBlockWriteAKM1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlBlockWriteAKM1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, pnlBlockWriteAKM1Layout.createSequentialGroup()
                        .addComponent(lblBWBlockAddressAKM1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(txtBWBlockAddressAKM1, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnBlockWriteAKM1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, pnlBlockWriteAKM1Layout.createSequentialGroup()
                        .addComponent(lblWriteDataAKM1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(chkBWHexAKM1))
                    .addComponent(txtWriteDataAKM1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 220, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(74, 74, 74))
        );
        pnlBlockWriteAKM1Layout.setVerticalGroup(
            pnlBlockWriteAKM1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlBlockWriteAKM1Layout.createSequentialGroup()
                .addComponent(lblBlockReadAKM3, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnlBlockWriteAKM1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblWriteDataAKM1)
                    .addComponent(chkBWHexAKM1))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(txtWriteDataAKM1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnlBlockWriteAKM1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblBWBlockAddressAKM1)
                    .addComponent(txtBWBlockAddressAKM1, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnBlockWriteAKM1, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        pnlBlockWriteAKM2.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

        txtWriteDataAKM2.setBackground(new java.awt.Color(249, 244, 244));
        txtWriteDataAKM2.setFont(new java.awt.Font("Verdana", 0, 11)); // NOI18N
        txtWriteDataAKM2.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        txtWriteDataAKM2.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

        txtBWBlockAddressAKM2.setFont(new java.awt.Font("Verdana", 1, 12)); // NOI18N
        txtBWBlockAddressAKM2.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        txtBWBlockAddressAKM2.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

        btnBlockWriteAKM2.setFont(new java.awt.Font("Verdana", 1, 11)); // NOI18N
        btnBlockWriteAKM2.setText("WRITE");
        btnBlockWriteAKM2.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        btnBlockWriteAKM2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnBlockWriteAKM2ActionPerformed(evt);
            }
        });

        lblBlockWriteAKM2.setBackground(new java.awt.Color(153, 153, 153));
        lblBlockWriteAKM2.setFont(new java.awt.Font("Verdana", 1, 12)); // NOI18N
        lblBlockWriteAKM2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        lblBlockWriteAKM2.setText("BlockWrite AKM2");
        lblBlockWriteAKM2.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        lblBlockWriteAKM2.setOpaque(true);

        lblBWBlockAddressAKM2.setFont(new java.awt.Font("Verdana", 0, 11)); // NOI18N
        lblBWBlockAddressAKM2.setText("Block Address");

        lblWriteDataAKM2.setFont(new java.awt.Font("Verdana", 0, 11)); // NOI18N
        lblWriteDataAKM2.setText("Write Data");

        chkBWHexAKM2.setFont(new java.awt.Font("Verdana", 0, 11)); // NOI18N
        chkBWHexAKM2.setText("Hex");
        chkBWHexAKM2.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));

        javax.swing.GroupLayout pnlBlockWriteAKM2Layout = new javax.swing.GroupLayout(pnlBlockWriteAKM2);
        pnlBlockWriteAKM2.setLayout(pnlBlockWriteAKM2Layout);
        pnlBlockWriteAKM2Layout.setHorizontalGroup(
            pnlBlockWriteAKM2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(lblBlockWriteAKM2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(pnlBlockWriteAKM2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlBlockWriteAKM2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pnlBlockWriteAKM2Layout.createSequentialGroup()
                        .addComponent(txtWriteDataAKM2, javax.swing.GroupLayout.PREFERRED_SIZE, 220, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(0, 1, Short.MAX_VALUE))
                    .addGroup(pnlBlockWriteAKM2Layout.createSequentialGroup()
                        .addComponent(lblWriteDataAKM2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(chkBWHexAKM2))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnlBlockWriteAKM2Layout.createSequentialGroup()
                        .addComponent(lblBWBlockAddressAKM2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(txtBWBlockAddressAKM2, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(10, 10, 10)
                        .addComponent(btnBlockWriteAKM2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addContainerGap())
        );
        pnlBlockWriteAKM2Layout.setVerticalGroup(
            pnlBlockWriteAKM2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlBlockWriteAKM2Layout.createSequentialGroup()
                .addComponent(lblBlockWriteAKM2, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(5, 5, 5)
                .addGroup(pnlBlockWriteAKM2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblWriteDataAKM2)
                    .addComponent(chkBWHexAKM2, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(0, 0, 0)
                .addComponent(txtWriteDataAKM2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnlBlockWriteAKM2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnBlockWriteAKM2, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtBWBlockAddressAKM2, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblBWBlockAddressAKM2))
                .addContainerGap())
        );

        pnlBlockWritePK.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

        txtWriteDataPK.setBackground(new java.awt.Color(249, 244, 244));
        txtWriteDataPK.setFont(new java.awt.Font("Verdana", 0, 11)); // NOI18N
        txtWriteDataPK.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        txtWriteDataPK.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

        txtBWBlockAddressPK.setFont(new java.awt.Font("Verdana", 1, 12)); // NOI18N
        txtBWBlockAddressPK.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        txtBWBlockAddressPK.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

        btnBlockWritePK.setFont(new java.awt.Font("Verdana", 1, 11)); // NOI18N
        btnBlockWritePK.setText("WRITE");
        btnBlockWritePK.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        btnBlockWritePK.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnBlockWritePKActionPerformed(evt);
            }
        });

        lblBlockWritePK.setBackground(new java.awt.Color(153, 153, 153));
        lblBlockWritePK.setFont(new java.awt.Font("Verdana", 1, 12)); // NOI18N
        lblBlockWritePK.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        lblBlockWritePK.setText("BlockWrite PK");
        lblBlockWritePK.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        lblBlockWritePK.setOpaque(true);

        lblBWBlockAddressPK.setFont(new java.awt.Font("Verdana", 0, 11)); // NOI18N
        lblBWBlockAddressPK.setText("Block Address");

        lblWriteDataPK.setFont(new java.awt.Font("Verdana", 0, 11)); // NOI18N
        lblWriteDataPK.setText("Write Data");

        chkBWHexPK.setFont(new java.awt.Font("Verdana", 0, 11)); // NOI18N
        chkBWHexPK.setText("Hex");
        chkBWHexPK.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));

        javax.swing.GroupLayout pnlBlockWritePKLayout = new javax.swing.GroupLayout(pnlBlockWritePK);
        pnlBlockWritePK.setLayout(pnlBlockWritePKLayout);
        pnlBlockWritePKLayout.setHorizontalGroup(
            pnlBlockWritePKLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(lblBlockWritePK, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(pnlBlockWritePKLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlBlockWritePKLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pnlBlockWritePKLayout.createSequentialGroup()
                        .addComponent(lblBWBlockAddressPK)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(txtBWBlockAddressPK, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(10, 10, 10)
                        .addComponent(btnBlockWritePK, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnlBlockWritePKLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addComponent(txtWriteDataPK, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 220, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, pnlBlockWritePKLayout.createSequentialGroup()
                            .addComponent(lblWriteDataPK)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(chkBWHexPK))))
                .addContainerGap())
        );
        pnlBlockWritePKLayout.setVerticalGroup(
            pnlBlockWritePKLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlBlockWritePKLayout.createSequentialGroup()
                .addComponent(lblBlockWritePK, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGroup(pnlBlockWritePKLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pnlBlockWritePKLayout.createSequentialGroup()
                        .addGap(2, 2, 2)
                        .addComponent(lblWriteDataPK)
                        .addGap(7, 7, 7))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnlBlockWritePKLayout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(chkBWHexPK, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
                .addComponent(txtWriteDataPK, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnlBlockWritePKLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnBlockWritePK, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtBWBlockAddressPK, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblBWBlockAddressPK))
                .addContainerGap())
        );

        javax.swing.GroupLayout jpnlBlockWriteLayout = new javax.swing.GroupLayout(jpnlBlockWrite);
        jpnlBlockWrite.setLayout(jpnlBlockWriteLayout);
        jpnlBlockWriteLayout.setHorizontalGroup(
            jpnlBlockWriteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jpnlBlockWriteLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jpnlBlockWriteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(pnlBlockWrite, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(pnlBlockWriteAKM2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jpnlBlockWriteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(pnlBlockWriteAKM1, 246, 246, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(pnlBlockWritePK, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap(23, Short.MAX_VALUE))
        );
        jpnlBlockWriteLayout.setVerticalGroup(
            jpnlBlockWriteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jpnlBlockWriteLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jpnlBlockWriteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(pnlBlockWriteAKM1, javax.swing.GroupLayout.DEFAULT_SIZE, 128, Short.MAX_VALUE)
                    .addComponent(pnlBlockWrite, javax.swing.GroupLayout.DEFAULT_SIZE, 128, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jpnlBlockWriteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(pnlBlockWriteAKM2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(pnlBlockWritePK, javax.swing.GroupLayout.DEFAULT_SIZE, 0, Short.MAX_VALUE))
                .addGap(13, 13, 13))
        );

        pgBlockReadWrite.addTab("Block Write", jpnlBlockWrite);

        getContentPane().add(pgBlockReadWrite, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 30, 539, 302));

        pnlHeader.setBackground(new java.awt.Color(255, 255, 255));
        pnlHeader.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

        rbAUTH1A.setBackground(new java.awt.Color(255, 255, 255));
        btngAUTH1AB.add(rbAUTH1A);
        rbAUTH1A.setFont(new java.awt.Font("Verdana", 0, 11)); // NOI18N
        rbAUTH1A.setSelected(true);
        rbAUTH1A.setText("AUTH 1A");
        rbAUTH1A.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));

        rbAUTH1B.setBackground(new java.awt.Color(255, 255, 255));
        btngAUTH1AB.add(rbAUTH1B);
        rbAUTH1B.setFont(new java.awt.Font("Verdana", 0, 11)); // NOI18N
        rbAUTH1B.setText("AUTH 1B");
        rbAUTH1B.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));

        lblKeyIndex.setFont(new java.awt.Font("Verdana", 0, 11)); // NOI18N
        lblKeyIndex.setText("Key Index");

        cboKeyIndex.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31" }));
        cboKeyIndex.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));

        jLabel1.setFont(new java.awt.Font("Verdana", 0, 11)); // NOI18N
        jLabel1.setText("PK");

        javax.swing.GroupLayout pnlHeaderLayout = new javax.swing.GroupLayout(pnlHeader);
        pnlHeader.setLayout(pnlHeaderLayout);
        pnlHeaderLayout.setHorizontalGroup(
            pnlHeaderLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlHeaderLayout.createSequentialGroup()
                .addGap(4, 4, 4)
                .addComponent(rbAUTH1A)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(rbAUTH1B)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(lblKeyIndex)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(cboKeyIndex, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel1)
                .addContainerGap(279, Short.MAX_VALUE))
        );
        pnlHeaderLayout.setVerticalGroup(
            pnlHeaderLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlHeaderLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(rbAUTH1A)
                .addComponent(rbAUTH1B)
                .addComponent(lblKeyIndex)
                .addComponent(cboKeyIndex, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(jLabel1))
        );

        getContentPane().add(pnlHeader, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 560, -1));

        lblFunction.setFont(new java.awt.Font("Verdana", 0, 11)); // NOI18N
        lblFunction.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        lblFunction.setText("Function Error");
        getContentPane().add(lblFunction, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 340, 140, 20));

        txtFErrorCode.setFont(new java.awt.Font("Verdana", 0, 11)); // NOI18N
        txtFErrorCode.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        txtFErrorCode.setText(" ");
        getContentPane().add(txtFErrorCode, new org.netbeans.lib.awtextra.AbsoluteConstraints(140, 340, 80, 20));

        txtFErrorExplain.setFont(new java.awt.Font("Verdana", 0, 11)); // NOI18N
        txtFErrorExplain.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        txtFErrorExplain.setText(" ");
        getContentPane().add(txtFErrorExplain, new org.netbeans.lib.awtextra.AbsoluteConstraints(220, 340, 340, 20));

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

    private byte[]  HexConvert(javax.swing.JTextField  txtTextBox) {
                
         String sTextBox=txtTextBox.getText();                
         byte[] bHexDecBuffer=new byte[MAX_BLOCK_BYTES];       
         byte bCharCounter=0;
         byte bCounter=0;                                                     
                  
         sTextBox=sTextBox.replaceAll("\\s","");
     try
     {
         while (bCharCounter<sTextBox.length())
           {                                          
               bHexDecBuffer[bCounter]=(byte) Short.parseShort(sTextBox.substring(bCharCounter,bCharCounter+2),16);                                   
               bCounter++;                              
               bCharCounter+=2;               
           } 
         if (bCounter<MAX_BLOCK_BYTES)
             throw new NumberFormatException("You must enter 16 bytes !");
     
     }catch(StringIndexOutOfBoundsException sout){
        throw new StringIndexOutOfBoundsException(APPROPRIATE_FORMAT);         
     }
           
       return bHexDecBuffer;
       
    }

        
    private String ConvertToHex(boolean chkCheck){                
        
        String sHexValue="";
        if (chkCheck){
            
            for (int iCounter=0;iCounter<MAX_BLOCK_BYTES;iCounter++){                  
                    sHexValue+=Integer.toHexString((((char) bBlockDataBuffer[iCounter] & 0xFF))).toUpperCase();  
                }        
        }
        else
        {
               sHexValue=new String(bBlockDataBuffer);
        }
        return sHexValue;
    }        
            
    private void formInternalFrameActivated(javax.swing.event.InternalFrameEvent evt) {//GEN-FIRST:event_formInternalFrameActivated
        new Global().CreateKey(312, 5, 31, 29, "txtPKKey", pnlHeader);
    }//GEN-LAST:event_formInternalFrameActivated

    private void btnBlockReadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBlockReadActionPerformed
        frmMain M = new frmMain();
        if (M.GetFunct() || M.GetLoop()) {
            return;
        }
        try
        {
          M.SetFunct(true);
          int iFResult        = 0;
          byte auth_mode      = (rbAUTH1A.isSelected() ? MIFARE_AUTHENT1A : MIFARE_AUTHENT1B);                              
          short block_address = 0;
          byte[]bBlockData    = new byte[MAX_BLOCK_BYTES];
          byte key_index      = (byte) cboKeyIndex.getSelectedIndex() ;                            
          String sString="";
        
            if (txtBlockAddress.getText().trim().isEmpty()) {
                JOptionPane.showMessageDialog(rootPane, "You must enter the  BLOCK ADDRESS !", "Warning !", JOptionPane.WARNING_MESSAGE);
                txtBlockAddress.requestFocus();
                return;
            }
            txtBlockRead.setText("");
            block_address = Byte.parseByte(txtBlockAddress.getText());
            
            iFResult = Declarations.UFrDeclarations.UFRInstance.BlockRead(bBlockData, block_address, auth_mode, key_index);
            if (iFResult == DL_OK) {                                                                                                         
                System.arraycopy(bBlockData,0,bBlockDataBuffer,0,16);                 
                txtBlockRead.setText(ConvertToHex(chkBRHex.isSelected()));                        
                Declarations.UFrDeclarations.UFRInstance.ReaderUISignal(FUNCT_LIGHT_OK, FUNCT_SOUND_OK);
                M.SetStatusBar(txtFErrorCode,txtFErrorExplain,iFResult);
            } else {
                Declarations.UFrDeclarations.UFRInstance.ReaderUISignal(FUNCT_LIGHT_ERROR,FUNCT_SOUND_ERROR);
                M.SetStatusBar(txtFErrorCode,txtFErrorExplain,iFResult);
            }
        } catch (NumberFormatException ex) {
            JOptionPane.showMessageDialog(rootPane, APPROPRIATE_FORMAT, "Error !", JOptionPane.ERROR_MESSAGE);
        } finally {
            M.SetFunct(false);
        }

    }//GEN-LAST:event_btnBlockReadActionPerformed

    private void btnBlockReadAKM1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBlockReadAKM1ActionPerformed
       frmMain M = new frmMain();
        if (M.GetFunct() || M.GetLoop()) {
            return;
        }
        try
        {
          M.SetFunct(true);
          int iFResult        = 0;
          byte auth_mode      = (rbAUTH1A.isSelected() ? MIFARE_AUTHENT1A : MIFARE_AUTHENT1B);                              
          short block_address = 0;
          byte[]bBlockData    = new byte[MAX_BLOCK_BYTES];

            if (txtBlockAddressAKM1.getText().trim().isEmpty()) {
                JOptionPane.showMessageDialog(rootPane, "You must enter the  BLOCK ADDRESS !", "Warning !", JOptionPane.WARNING_MESSAGE);
                txtBlockAddressAKM1.requestFocus();
                return;
            }
            txtBlockReadAKM1.setText("");
            block_address = Byte.parseByte(txtBlockAddressAKM1.getText());
            
            iFResult = Declarations.UFrDeclarations.UFRInstance.BlockRead_AKM1(bBlockData, block_address, auth_mode);
            if (iFResult == DL_OK) {
                                                
                System.arraycopy(bBlockData,0,bBlockDataBuffer,0,16); 
                txtBlockReadAKM1.setText(ConvertToHex(chkBRHexAKM1.isSelected()));               
                Declarations.UFrDeclarations.UFRInstance.ReaderUISignal(FUNCT_LIGHT_OK, FUNCT_SOUND_OK);
                M.SetStatusBar(txtFErrorCode,txtFErrorExplain,iFResult);
            } else {
                Declarations.UFrDeclarations.UFRInstance.ReaderUISignal(FUNCT_LIGHT_ERROR,FUNCT_SOUND_ERROR);
                M.SetStatusBar(txtFErrorCode,txtFErrorExplain,iFResult);
            }
        } catch (NumberFormatException ex) {
            JOptionPane.showMessageDialog(rootPane, APPROPRIATE_FORMAT, "Error !", JOptionPane.ERROR_MESSAGE);
        } finally {
            M.SetFunct(false);
        }

    }//GEN-LAST:event_btnBlockReadAKM1ActionPerformed

    private void btnBlockReadAKM2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBlockReadAKM2ActionPerformed
        frmMain M = new frmMain();
        if (M.GetFunct() || M.GetLoop()) {
            return;
        }
        try
        {
          M.SetFunct(true);
          int iFResult        = 0;
          byte auth_mode      = (rbAUTH1A.isSelected() ? MIFARE_AUTHENT1A : MIFARE_AUTHENT1B);                              
          short block_address = 0;
          byte[]bBlockData    = new byte[MAX_BLOCK_BYTES];

            if (txtBlockAddressAKM2.getText().trim().isEmpty()) {
                JOptionPane.showMessageDialog(rootPane, "You must enter the  BLOCK ADDRESS !", "Warning !", JOptionPane.WARNING_MESSAGE);
                txtBlockAddressAKM2.requestFocus();
                return;
            }
            txtBlockReadAKM2.setText("");
            block_address = Byte.parseByte(txtBlockAddressAKM2.getText());
            
            iFResult = Declarations.UFrDeclarations.UFRInstance.BlockRead_AKM2(bBlockData, block_address, auth_mode);
            if (iFResult == DL_OK) {
                                             
                System.arraycopy(bBlockData,0,bBlockDataBuffer,0,16);
                txtBlockReadAKM2.setText(ConvertToHex(chkBRHexAKM2.isSelected()));
                Declarations.UFrDeclarations.UFRInstance.ReaderUISignal(FUNCT_LIGHT_OK, FUNCT_SOUND_OK);
                M.SetStatusBar(txtFErrorCode,txtFErrorExplain,iFResult);
            } else {
                Declarations.UFrDeclarations.UFRInstance.ReaderUISignal(FUNCT_LIGHT_ERROR,FUNCT_SOUND_ERROR);
                M.SetStatusBar(txtFErrorCode,txtFErrorExplain,iFResult);
            }
        } catch (NumberFormatException ex) {
            JOptionPane.showMessageDialog(rootPane, APPROPRIATE_FORMAT, "Error !", JOptionPane.ERROR_MESSAGE);
        } finally {
            M.SetFunct(false);
        }

    }//GEN-LAST:event_btnBlockReadAKM2ActionPerformed

    private void btnBlockReadPKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBlockReadPKActionPerformed
        frmMain M = new frmMain();
        if (M.GetFunct() || M.GetLoop()) {
            return;
        }
        try
        {
          M.SetFunct(true);
          int iFResult        = 0;
          byte auth_mode      = (rbAUTH1A.isSelected() ? MIFARE_AUTHENT1A : MIFARE_AUTHENT1B);                              
          short block_address = 0;
          byte[]bBlockData    = new byte[MAX_BLOCK_BYTES];

            if (txtBlockAddressPK.getText().trim().isEmpty()) {
                JOptionPane.showMessageDialog(rootPane, "You must enter the  BLOCK ADDRESS !", "Warning !", JOptionPane.WARNING_MESSAGE);
                txtBlockAddressPK.requestFocus();
                return;
            }
            txtBlockReadPK.setText("");
            block_address = Byte.parseByte(txtBlockAddressPK.getText());
           
            iFResult = Declarations.UFrDeclarations.UFRInstance.BlockRead_PK(bBlockData, block_address, auth_mode, new Global() .PK_KEY(pnlHeader));
            if (iFResult == DL_OK) {
                                              
                System.arraycopy(bBlockData,0,bBlockDataBuffer,0,16);
                txtBlockReadPK.setText(ConvertToHex(chkBRHexPK.isSelected()));
                Declarations.UFrDeclarations.UFRInstance.ReaderUISignal(FUNCT_LIGHT_OK, FUNCT_SOUND_OK);
                M.SetStatusBar(txtFErrorCode,txtFErrorExplain,iFResult);
            } else {
                Declarations.UFrDeclarations.UFRInstance.ReaderUISignal(FUNCT_LIGHT_ERROR,FUNCT_SOUND_ERROR);
                M.SetStatusBar(txtFErrorCode,txtFErrorExplain,iFResult);
            }
        } catch (NumberFormatException ex) {
            JOptionPane.showMessageDialog(rootPane, APPROPRIATE_FORMAT, "Error !", JOptionPane.ERROR_MESSAGE);
        } finally {
            M.SetFunct(false);
        }

    }//GEN-LAST:event_btnBlockReadPKActionPerformed

    private void btnBlockWriteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBlockWriteActionPerformed
        frmMain M = new frmMain();
        if (M.GetFunct() || M.GetLoop()) {
            return;
        }
        try
        {
          M.SetFunct(true);
          int iFResult        = 0;
          byte auth_mode      = (rbAUTH1A.isSelected() ? MIFARE_AUTHENT1A : MIFARE_AUTHENT1B);                              
          short block_address = 0;
          byte[]bBlockData    = new byte[MAX_BLOCK_BYTES];
          byte[] write_data   = new byte[20];
          byte key_index =(byte) cboKeyIndex.getSelectedIndex();
          String sString="";
       
            if (txtWriteData.getText().trim().isEmpty()) {
                JOptionPane.showMessageDialog(rootPane, ANY_DATA, "Warning !", JOptionPane.WARNING_MESSAGE);
                txtWriteData.requestFocus();
                return;
            }
            if (txtBWBlockAddress.getText().trim().isEmpty()) {
                JOptionPane.showMessageDialog(rootPane, "You must enter the  BLOCK ADDRESS !", "Warning !", JOptionPane.WARNING_MESSAGE);
                txtBWBlockAddress.requestFocus();
                return;
            }

            block_address = Byte.parseByte(txtBWBlockAddress.getText());
                    
            if (chkBWHex.isSelected()){
                write_data=HexConvert(txtWriteData);
            }
            else
            {
               write_data=txtWriteData.getText().getBytes();                          
            }                               
            iFResult = Declarations.UFrDeclarations.UFRInstance.BlockWrite(write_data, block_address, auth_mode, key_index);
            if (iFResult == DL_OK) {
                Declarations.UFrDeclarations.UFRInstance.ReaderUISignal(FUNCT_LIGHT_OK, FUNCT_SOUND_OK);
                M.SetStatusBar(txtFErrorCode,txtFErrorExplain,iFResult);
            } else {
                Declarations.UFrDeclarations.UFRInstance.ReaderUISignal(FUNCT_LIGHT_ERROR,FUNCT_SOUND_ERROR);
                M.SetStatusBar(txtFErrorCode,txtFErrorExplain,iFResult);
            }
        } catch (NumberFormatException ex) {
            JOptionPane.showMessageDialog(rootPane, APPROPRIATE_FORMAT, "Error !", JOptionPane.ERROR_MESSAGE);
        } finally {
            M.SetFunct(false);
        }

    }//GEN-LAST:event_btnBlockWriteActionPerformed

    private void btnBlockWriteAKM1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBlockWriteAKM1ActionPerformed
       frmMain M = new frmMain();
        if (M.GetFunct() || M.GetLoop()) {
            return;
        }
        try
        {
          M.SetFunct(true);
          int iFResult        = 0;
          byte auth_mode      = (rbAUTH1A.isSelected() ? MIFARE_AUTHENT1A : MIFARE_AUTHENT1B);                              
          short block_address = 0;
          byte[]bBlockData    = new byte[MAX_BLOCK_BYTES];
          byte[] write_data   = new byte[20];
          
        
          
            if (txtWriteDataAKM1.getText().trim().isEmpty()) {
                JOptionPane.showMessageDialog(rootPane, ANY_DATA, "Warning !", JOptionPane.WARNING_MESSAGE);
                txtWriteDataAKM1.requestFocus();
                return;
            }
            if (txtBWBlockAddressAKM1.getText().trim().isEmpty()) {
                JOptionPane.showMessageDialog(rootPane, "You must enter the  BLOCK ADDRESS !", "Warning !", JOptionPane.WARNING_MESSAGE);
                txtBWBlockAddressAKM1.requestFocus();
                return;
            }
            
            block_address = Byte.parseByte(txtBWBlockAddressAKM1.getText());
            
            if (chkBWHexAKM1.isSelected()){
                write_data=HexConvert(txtWriteDataAKM1);
            }
            else
            {
               write_data=txtWriteDataAKM1.getText().getBytes();                          
            }
            
            iFResult = Declarations.UFrDeclarations.UFRInstance.BlockWrite_AKM1(write_data, block_address, auth_mode);

            if (iFResult == DL_OK) {
                Declarations.UFrDeclarations.UFRInstance.ReaderUISignal(FUNCT_LIGHT_OK, FUNCT_SOUND_OK);
                M.SetStatusBar(txtFErrorCode,txtFErrorExplain,iFResult);
            } else {
                Declarations.UFrDeclarations.UFRInstance.ReaderUISignal(FUNCT_LIGHT_ERROR,FUNCT_SOUND_ERROR);
                M.SetStatusBar(txtFErrorCode,txtFErrorExplain,iFResult);
            }
        } catch (NumberFormatException ex) {
            JOptionPane.showMessageDialog(rootPane, APPROPRIATE_FORMAT, "Error !", JOptionPane.ERROR_MESSAGE);
        } finally {
            M.SetFunct(false);
        }

    }//GEN-LAST:event_btnBlockWriteAKM1ActionPerformed

    private void btnBlockWriteAKM2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBlockWriteAKM2ActionPerformed
       frmMain M = new frmMain();
        if (M.GetFunct() || M.GetLoop()) {
            return;
        }
        try
        {
          M.SetFunct(true);
          int iFResult        = 0;
          byte auth_mode      = (rbAUTH1A.isSelected() ? MIFARE_AUTHENT1A : MIFARE_AUTHENT1B);                              
          short block_address = 0;
          byte[]bBlockData    = new byte[MAX_BLOCK_BYTES];
          byte[] write_data   = new byte[20];
          
            if (txtWriteDataAKM2.getText().trim().isEmpty()) {
                JOptionPane.showMessageDialog(rootPane, ANY_DATA, "Warning !", JOptionPane.WARNING_MESSAGE);
                txtWriteDataAKM2.requestFocus();
                return;
            }
            if (txtBWBlockAddressAKM2.getText().trim().isEmpty()) {
                JOptionPane.showMessageDialog(rootPane, "You must enter the  BLOCK ADDRESS !", "Warning !", JOptionPane.WARNING_MESSAGE);
                txtBWBlockAddressAKM2.requestFocus();
                return;
            }            
            block_address = Byte.parseByte(txtBWBlockAddressAKM2.getText());                        
            if (chkBWHexAKM2.isSelected()){
                write_data=HexConvert(txtWriteDataAKM2);
            }
            else
            {
               write_data=txtWriteDataAKM2.getText().getBytes();                          
            }
            
            iFResult = Declarations.UFrDeclarations.UFRInstance.BlockWrite_AKM2(write_data, block_address, auth_mode);

            if (iFResult == DL_OK) {
                Declarations.UFrDeclarations.UFRInstance.ReaderUISignal(FUNCT_LIGHT_OK, FUNCT_SOUND_OK);
                M.SetStatusBar(txtFErrorCode,txtFErrorExplain,iFResult);
            } else {
                Declarations.UFrDeclarations.UFRInstance.ReaderUISignal(FUNCT_LIGHT_ERROR,FUNCT_SOUND_ERROR);
                M.SetStatusBar(txtFErrorCode,txtFErrorExplain,iFResult);
            }
        } catch (NumberFormatException ex) {
            JOptionPane.showMessageDialog(rootPane, APPROPRIATE_FORMAT, "Error !", JOptionPane.ERROR_MESSAGE);
        } finally {
            M.SetFunct(false);
        }

    }//GEN-LAST:event_btnBlockWriteAKM2ActionPerformed

    private void btnBlockWritePKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBlockWritePKActionPerformed
         frmMain M = new frmMain();
        if (M.GetFunct() || M.GetLoop()) {
            return;
        }
        try
        {
          M.SetFunct(true);
          int iFResult        = 0;
          byte auth_mode      = (rbAUTH1A.isSelected() ? MIFARE_AUTHENT1A : MIFARE_AUTHENT1B);                              
          short block_address = 0;
          byte[]bBlockData    = new byte[MAX_BLOCK_BYTES];
          byte[] write_data   = new byte[20];
          
            if (txtWriteDataPK.getText().trim().isEmpty()) {
                JOptionPane.showMessageDialog(rootPane, ANY_DATA, "Warning !", JOptionPane.WARNING_MESSAGE);
                txtWriteDataPK.requestFocus();
                return;
            }
            if (txtBWBlockAddressPK.getText().trim().isEmpty()) {
                JOptionPane.showMessageDialog(rootPane, "You must enter the  BLOCK ADDRESS !", "Warning !", JOptionPane.WARNING_MESSAGE);
                txtBWBlockAddressPK.requestFocus();
                return;
            }            
            block_address = Byte.parseByte(txtBWBlockAddressPK.getText());
            
            if (chkBWHexPK.isSelected()){
                write_data=HexConvert(txtWriteDataPK);
            }
            else
            {
               write_data=txtWriteDataPK.getText().getBytes();                          
            }
            iFResult = Declarations.UFrDeclarations.UFRInstance.BlockWrite_PK(write_data, block_address, auth_mode, new Global().PK_KEY(pnlHeader));

            if (iFResult == DL_OK) {
               Declarations.UFrDeclarations.UFRInstance.ReaderUISignal(FUNCT_LIGHT_OK, FUNCT_SOUND_OK);
                M.SetStatusBar(txtFErrorCode,txtFErrorExplain,iFResult);
            } else {
                Declarations.UFrDeclarations.UFRInstance.ReaderUISignal(FUNCT_LIGHT_ERROR,FUNCT_SOUND_ERROR);
                M.SetStatusBar(txtFErrorCode,txtFErrorExplain,iFResult);
            }
        } catch (NumberFormatException ex) {
            JOptionPane.showMessageDialog(rootPane, APPROPRIATE_FORMAT, "Error !", JOptionPane.ERROR_MESSAGE);
        } finally {
            M.SetFunct(false);
        }

    }//GEN-LAST:event_btnBlockWritePKActionPerformed

    private void chkBRHexItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_chkBRHexItemStateChanged
        
           // txtBlockRead.setText(new String(ConvertToHex(bBlockDataBuffer,evt)).toUpperCase());                    
    }//GEN-LAST:event_chkBRHexItemStateChanged

    private void chkBRHexAKM1ItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_chkBRHexAKM1ItemStateChanged
       //  txtBlockReadAKM1.setText(new String(ConvertToHex(bBlockDataBuffer,evt)).toUpperCase());
    }//GEN-LAST:event_chkBRHexAKM1ItemStateChanged

    private void chkBRHexAKM2ItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_chkBRHexAKM2ItemStateChanged
      //  txtBlockReadAKM2.setText(new String(ConvertToHex(bBlockDataBuffer,evt)).toUpperCase());
    }//GEN-LAST:event_chkBRHexAKM2ItemStateChanged

    private void chkBRHexPKItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_chkBRHexPKItemStateChanged
      //  txtBlockReadPK.setText(new String(ConvertToHex(bBlockDataBuffer,evt)).toUpperCase());
    }//GEN-LAST:event_chkBRHexPKItemStateChanged

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnBlockRead;
    private javax.swing.JButton btnBlockReadAKM1;
    private javax.swing.JButton btnBlockReadAKM2;
    private javax.swing.JButton btnBlockReadPK;
    private javax.swing.JButton btnBlockWrite;
    private javax.swing.JButton btnBlockWriteAKM1;
    private javax.swing.JButton btnBlockWriteAKM2;
    private javax.swing.JButton btnBlockWritePK;
    private javax.swing.ButtonGroup btngAUTH1AB;
    private javax.swing.JComboBox cboKeyIndex;
    private javax.swing.JCheckBox chkBRHex;
    private javax.swing.JCheckBox chkBRHexAKM1;
    private javax.swing.JCheckBox chkBRHexAKM2;
    private javax.swing.JCheckBox chkBRHexPK;
    private javax.swing.JCheckBox chkBWHex;
    private javax.swing.JCheckBox chkBWHexAKM1;
    private javax.swing.JCheckBox chkBWHexAKM2;
    private javax.swing.JCheckBox chkBWHexPK;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JPanel jpnlBlockWrite;
    private javax.swing.JLabel lblBWBlockAddress;
    private javax.swing.JLabel lblBWBlockAddressAKM1;
    private javax.swing.JLabel lblBWBlockAddressAKM2;
    private javax.swing.JLabel lblBWBlockAddressPK;
    private javax.swing.JLabel lblBlockRead;
    private javax.swing.JLabel lblBlockReadAKM1;
    private javax.swing.JLabel lblBlockReadAKM2;
    private javax.swing.JLabel lblBlockReadAKM3;
    private javax.swing.JLabel lblBlockReadPK;
    private javax.swing.JLabel lblBlockWrite;
    private javax.swing.JLabel lblBlockWriteAKM2;
    private javax.swing.JLabel lblBlockWritePK;
    private javax.swing.JTextField lblFunction;
    private javax.swing.JLabel lblKeyIndex;
    private javax.swing.JLabel lblReadData;
    private javax.swing.JLabel lblReadDataAKM1;
    private javax.swing.JLabel lblReadDataAKM2;
    private javax.swing.JLabel lblReadDataPK;
    private javax.swing.JLabel lblWriteData;
    private javax.swing.JLabel lblWriteDataAKM1;
    private javax.swing.JLabel lblWriteDataAKM2;
    private javax.swing.JLabel lblWriteDataPK;
    private javax.swing.JLabel lblblockAddress;
    private javax.swing.JLabel lblblockAddressAKM1;
    private javax.swing.JLabel lblblockAddressAKM2;
    private javax.swing.JLabel lblblockAddressPK;
    private javax.swing.JTabbedPane pgBlockReadWrite;
    private javax.swing.JPanel pnlBlockRead;
    private javax.swing.JPanel pnlBlockReadAKM1;
    private javax.swing.JPanel pnlBlockReadAKM2;
    private javax.swing.JPanel pnlBlockReadPK;
    private javax.swing.JPanel pnlBlockWrite;
    private javax.swing.JPanel pnlBlockWriteAKM1;
    private javax.swing.JPanel pnlBlockWriteAKM2;
    private javax.swing.JPanel pnlBlockWritePK;
    private javax.swing.JPanel pnlHeader;
    private javax.swing.JRadioButton rbAUTH1A;
    private javax.swing.JRadioButton rbAUTH1B;
    private javax.swing.JPanel tabBlockRead;
    private javax.swing.JTextField txtBWBlockAddress;
    private javax.swing.JTextField txtBWBlockAddressAKM1;
    private javax.swing.JTextField txtBWBlockAddressAKM2;
    private javax.swing.JTextField txtBWBlockAddressPK;
    private javax.swing.JTextField txtBlockAddress;
    private javax.swing.JTextField txtBlockAddressAKM1;
    private javax.swing.JTextField txtBlockAddressAKM2;
    private javax.swing.JTextField txtBlockAddressPK;
    private javax.swing.JTextField txtBlockRead;
    private javax.swing.JTextField txtBlockReadAKM1;
    private javax.swing.JTextField txtBlockReadAKM2;
    private javax.swing.JTextField txtBlockReadPK;
    private javax.swing.JTextField txtFErrorCode;
    private javax.swing.JTextField txtFErrorExplain;
    private javax.swing.JTextField txtWriteData;
    private javax.swing.JTextField txtWriteDataAKM1;
    private javax.swing.JTextField txtWriteDataAKM2;
    private javax.swing.JTextField txtWriteDataPK;
    // End of variables declaration//GEN-END:variables
}
