package ufradvanced;

import javax.swing.JOptionPane;

public class frmSectorTrailerWrite extends javax.swing.JInternalFrame {

    public frmSectorTrailerWrite() {
        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;
         
    
    private final static String ANY_DATA           = "You must enter any data !",
                                APPROPRIATE_FORMAT = "You must enter the appropriate format !";

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        btngAUTH1AB = new javax.swing.ButtonGroup();
        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();
        pnlKeyAB = new javax.swing.JPanel();
        pnlKeyA = new javax.swing.JPanel();
        lblKeyA = new javax.swing.JLabel();
        chkHexKeyA = new javax.swing.JCheckBox();
        pnlKeyB = new javax.swing.JPanel();
        lblKeyB = new javax.swing.JLabel();
        chkHexKeyB = new javax.swing.JCheckBox();
        pgSectorTrailerWrite = new javax.swing.JTabbedPane();
        tabSectorTrailerWrite = new javax.swing.JPanel();
        lblAddressingMode = new javax.swing.JLabel();
        cboAddressingMode = new javax.swing.JComboBox();
        lblBlockOrSectorAddress = new javax.swing.JLabel();
        txtBlockOrSectorAddress = new javax.swing.JTextField();
        lblAccessBits0 = new javax.swing.JLabel();
        cboAccessBits0 = new javax.swing.JComboBox();
        lblAccessBits1 = new javax.swing.JLabel();
        cboAccessBits1 = new javax.swing.JComboBox();
        lblAccessBits2 = new javax.swing.JLabel();
        cboAccessBits2 = new javax.swing.JComboBox();
        lblTrailerAccessBits = new javax.swing.JLabel();
        cboTrailerAccessBits = new javax.swing.JComboBox();
        lblTrailerByte9 = new javax.swing.JLabel();
        txtTrailerByte9 = new javax.swing.JTextField();
        btnSectorTrailerWrite = new javax.swing.JButton();
        tabSectorTrailerWriteAKM1 = new javax.swing.JPanel();
        lblAddressingModeAKM1 = new javax.swing.JLabel();
        cboAddressingModeAKM1 = new javax.swing.JComboBox();
        lblBlockOrSectorAddressAKM1 = new javax.swing.JLabel();
        txtBlockOrSectorAddressAKM1 = new javax.swing.JTextField();
        lblAccessBits0AKM1 = new javax.swing.JLabel();
        cboAccessBits0AKM1 = new javax.swing.JComboBox();
        lblAccessBits1AKM1 = new javax.swing.JLabel();
        cboAccessBits1AKM1 = new javax.swing.JComboBox();
        lblAccessBits2AKM1 = new javax.swing.JLabel();
        cboAccessBits2AKM1 = new javax.swing.JComboBox();
        lblTrailerAccessBitsAKM1 = new javax.swing.JLabel();
        cboTrailerAccessBitsAKM1 = new javax.swing.JComboBox();
        lblTrailerByte9AKM1 = new javax.swing.JLabel();
        txtTrailerByte9AKM1 = new javax.swing.JTextField();
        btnSectorTrailerWriteAKM1 = new javax.swing.JButton();
        tabSectorTrailerWriteAKM2 = new javax.swing.JPanel();
        lblAddressingModeAKM2 = new javax.swing.JLabel();
        cboAddressingModeAKM2 = new javax.swing.JComboBox();
        lblBlockOrSectorAddressAKM2 = new javax.swing.JLabel();
        txtBlockOrSectorAddressAKM2 = new javax.swing.JTextField();
        lblAccessBits0AKM2 = new javax.swing.JLabel();
        cboAccessBits0AKM2 = new javax.swing.JComboBox();
        lblAccessBits1AKM2 = new javax.swing.JLabel();
        cboAccessBits1AKM2 = new javax.swing.JComboBox();
        lblAccessBits2AKM2 = new javax.swing.JLabel();
        cboAccessBits2AKM2 = new javax.swing.JComboBox();
        lblTrailerAccessBitsAKM2 = new javax.swing.JLabel();
        cboTrailerAccessBitsAKM2 = new javax.swing.JComboBox();
        lblTrailerByte9AKM2 = new javax.swing.JLabel();
        txtTrailerByte9AKM2 = new javax.swing.JTextField();
        btnSectorTrailerWriteAKM2 = new javax.swing.JButton();
        tabSectorTrailerWritePK = new javax.swing.JPanel();
        lblAddressingModePK = new javax.swing.JLabel();
        cboAddressingModePK = new javax.swing.JComboBox();
        lblBlockOrSectorAddressPK = new javax.swing.JLabel();
        txtBlockOrSectorAddressPK = new javax.swing.JTextField();
        lblAccessBits0PK = new javax.swing.JLabel();
        cboAccessBits0PK = new javax.swing.JComboBox();
        lblAccessBits1PK = new javax.swing.JLabel();
        cboAccessBits1PK = new javax.swing.JComboBox();
        lblAccessBits2PK = new javax.swing.JLabel();
        cboAccessBits2PK = new javax.swing.JComboBox();
        lblTrailerAccessBitsPK = new javax.swing.JLabel();
        cboTrailerAccessBitsPK = new javax.swing.JComboBox();
        lblTrailerByte9PK = new javax.swing.JLabel();
        txtTrailerByte9PK = new javax.swing.JTextField();
        btnSectorTrailerWritePK = new javax.swing.JButton();
        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("frmSectorTrailerWrite");
        setName("frmSectorTrailerWrite"); // NOI18N
        setOpaque(true);
        setPreferredSize(new java.awt.Dimension(555, 385));
        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());

        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(299, 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, 580, -1));

        pnlKeyA.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        pnlKeyA.setPreferredSize(new java.awt.Dimension(276, 116));

        lblKeyA.setBackground(new java.awt.Color(204, 204, 204));
        lblKeyA.setFont(new java.awt.Font("Verdana", 1, 11)); // NOI18N
        lblKeyA.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        lblKeyA.setText("KEY A");
        lblKeyA.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        lblKeyA.setOpaque(true);

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

        javax.swing.GroupLayout pnlKeyALayout = new javax.swing.GroupLayout(pnlKeyA);
        pnlKeyA.setLayout(pnlKeyALayout);
        pnlKeyALayout.setHorizontalGroup(
            pnlKeyALayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(lblKeyA, javax.swing.GroupLayout.DEFAULT_SIZE, 274, Short.MAX_VALUE)
            .addGroup(pnlKeyALayout.createSequentialGroup()
                .addGap(43, 43, 43)
                .addComponent(chkHexKeyA)
                .addContainerGap(184, Short.MAX_VALUE))
        );
        pnlKeyALayout.setVerticalGroup(
            pnlKeyALayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlKeyALayout.createSequentialGroup()
                .addComponent(lblKeyA, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 49, Short.MAX_VALUE)
                .addComponent(chkHexKeyA)
                .addContainerGap())
        );

        pnlKeyB.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        pnlKeyB.setPreferredSize(new java.awt.Dimension(276, 116));

        lblKeyB.setBackground(new java.awt.Color(204, 204, 204));
        lblKeyB.setFont(new java.awt.Font("Verdana", 1, 11)); // NOI18N
        lblKeyB.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        lblKeyB.setText("KEY B");
        lblKeyB.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        lblKeyB.setOpaque(true);

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

        javax.swing.GroupLayout pnlKeyBLayout = new javax.swing.GroupLayout(pnlKeyB);
        pnlKeyB.setLayout(pnlKeyBLayout);
        pnlKeyBLayout.setHorizontalGroup(
            pnlKeyBLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(lblKeyB, javax.swing.GroupLayout.DEFAULT_SIZE, 269, Short.MAX_VALUE)
            .addGroup(pnlKeyBLayout.createSequentialGroup()
                .addGap(41, 41, 41)
                .addComponent(chkHexKeyB)
                .addContainerGap(181, Short.MAX_VALUE))
        );
        pnlKeyBLayout.setVerticalGroup(
            pnlKeyBLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlKeyBLayout.createSequentialGroup()
                .addComponent(lblKeyB, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 49, Short.MAX_VALUE)
                .addComponent(chkHexKeyB)
                .addContainerGap())
        );

        javax.swing.GroupLayout pnlKeyABLayout = new javax.swing.GroupLayout(pnlKeyAB);
        pnlKeyAB.setLayout(pnlKeyABLayout);
        pnlKeyABLayout.setHorizontalGroup(
            pnlKeyABLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlKeyABLayout.createSequentialGroup()
                .addComponent(pnlKeyA, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(pnlKeyB, javax.swing.GroupLayout.PREFERRED_SIZE, 271, javax.swing.GroupLayout.PREFERRED_SIZE))
        );
        pnlKeyABLayout.setVerticalGroup(
            pnlKeyABLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(pnlKeyA, javax.swing.GroupLayout.DEFAULT_SIZE, 103, Short.MAX_VALUE)
            .addComponent(pnlKeyB, javax.swing.GroupLayout.DEFAULT_SIZE, 103, Short.MAX_VALUE)
        );

        getContentPane().add(pnlKeyAB, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 31, 580, -1));

        pgSectorTrailerWrite.setTabLayoutPolicy(javax.swing.JTabbedPane.SCROLL_TAB_LAYOUT);
        pgSectorTrailerWrite.setFont(new java.awt.Font("Verdana", 1, 11)); // NOI18N

        lblAddressingMode.setFont(new java.awt.Font("Verdana", 0, 11)); // NOI18N
        lblAddressingMode.setText("Addressing Mode");

        cboAddressingMode.setFont(new java.awt.Font("Verdana", 1, 11)); // NOI18N
        cboAddressingMode.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "0", "1" }));
        cboAddressingMode.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));

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

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

        lblAccessBits0.setFont(new java.awt.Font("Verdana", 0, 11)); // NOI18N
        lblAccessBits0.setText("Access Bits 0");

        cboAccessBits0.setFont(new java.awt.Font("Verdana", 1, 11)); // NOI18N
        cboAccessBits0.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "0", "1", "2", "3", "4", "5", "6", "7" }));
        cboAccessBits0.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));

        lblAccessBits1.setFont(new java.awt.Font("Verdana", 0, 11)); // NOI18N
        lblAccessBits1.setText("Access Bits 1");

        cboAccessBits1.setFont(new java.awt.Font("Verdana", 1, 11)); // NOI18N
        cboAccessBits1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "0", "1", "2", "3", "4", "5", "6", "7" }));
        cboAccessBits1.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));

        lblAccessBits2.setFont(new java.awt.Font("Verdana", 0, 11)); // NOI18N
        lblAccessBits2.setText("Access Bits 2");

        cboAccessBits2.setFont(new java.awt.Font("Verdana", 1, 11)); // NOI18N
        cboAccessBits2.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "0", "1", "2", "3", "4", "5", "6", "7" }));
        cboAccessBits2.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));

        lblTrailerAccessBits.setFont(new java.awt.Font("Verdana", 0, 11)); // NOI18N
        lblTrailerAccessBits.setText("Trailer Access Bits");

        cboTrailerAccessBits.setFont(new java.awt.Font("Verdana", 1, 11)); // NOI18N
        cboTrailerAccessBits.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "0", "1", "2", "3", "4", "5", "6", "7" }));
        cboTrailerAccessBits.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));

        lblTrailerByte9.setFont(new java.awt.Font("Verdana", 0, 11)); // NOI18N
        lblTrailerByte9.setText("Trailer Byte 9");

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

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

        javax.swing.GroupLayout tabSectorTrailerWriteLayout = new javax.swing.GroupLayout(tabSectorTrailerWrite);
        tabSectorTrailerWrite.setLayout(tabSectorTrailerWriteLayout);
        tabSectorTrailerWriteLayout.setHorizontalGroup(
            tabSectorTrailerWriteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(tabSectorTrailerWriteLayout.createSequentialGroup()
                .addGap(44, 44, 44)
                .addGroup(tabSectorTrailerWriteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lblAddressingMode)
                    .addComponent(lblBlockOrSectorAddress)
                    .addComponent(lblAccessBits0)
                    .addComponent(lblAccessBits1)
                    .addComponent(lblAccessBits2))
                .addGap(14, 14, 14)
                .addGroup(tabSectorTrailerWriteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(cboAccessBits2, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(cboAccessBits1, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(cboAccessBits0, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(txtBlockOrSectorAddress)
                    .addComponent(cboAddressingMode, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(67, 67, 67)
                .addGroup(tabSectorTrailerWriteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(tabSectorTrailerWriteLayout.createSequentialGroup()
                        .addGroup(tabSectorTrailerWriteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lblTrailerAccessBits)
                            .addComponent(lblTrailerByte9))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGroup(tabSectorTrailerWriteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(cboTrailerAccessBits, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(txtTrailerByte9, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addComponent(btnSectorTrailerWrite, javax.swing.GroupLayout.PREFERRED_SIZE, 187, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(66, 66, 66))
        );
        tabSectorTrailerWriteLayout.setVerticalGroup(
            tabSectorTrailerWriteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(tabSectorTrailerWriteLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(tabSectorTrailerWriteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(tabSectorTrailerWriteLayout.createSequentialGroup()
                        .addGroup(tabSectorTrailerWriteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(lblAddressingMode)
                            .addComponent(cboAddressingMode, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(tabSectorTrailerWriteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(lblBlockOrSectorAddress, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(txtBlockOrSectorAddress, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(tabSectorTrailerWriteLayout.createSequentialGroup()
                        .addGroup(tabSectorTrailerWriteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(lblTrailerAccessBits)
                            .addComponent(cboTrailerAccessBits, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(tabSectorTrailerWriteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(lblTrailerByte9, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(txtTrailerByte9, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(tabSectorTrailerWriteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(tabSectorTrailerWriteLayout.createSequentialGroup()
                        .addGap(1, 1, 1)
                        .addComponent(lblAccessBits0)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(lblAccessBits1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(lblAccessBits2))
                    .addGroup(tabSectorTrailerWriteLayout.createSequentialGroup()
                        .addComponent(cboAccessBits0, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(cboAccessBits1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(cboAccessBits2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(btnSectorTrailerWrite, javax.swing.GroupLayout.PREFERRED_SIZE, 77, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(19, Short.MAX_VALUE))
        );

        pgSectorTrailerWrite.addTab("SectorTrailer Write", tabSectorTrailerWrite);

        lblAddressingModeAKM1.setFont(new java.awt.Font("Verdana", 0, 11)); // NOI18N
        lblAddressingModeAKM1.setText("Addressing Mode");

        cboAddressingModeAKM1.setFont(new java.awt.Font("Verdana", 1, 11)); // NOI18N
        cboAddressingModeAKM1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "0", "1" }));
        cboAddressingModeAKM1.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));

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

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

        lblAccessBits0AKM1.setFont(new java.awt.Font("Verdana", 0, 11)); // NOI18N
        lblAccessBits0AKM1.setText("Access Bits 0");

        cboAccessBits0AKM1.setFont(new java.awt.Font("Verdana", 1, 11)); // NOI18N
        cboAccessBits0AKM1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "0", "1", "2", "3", "4", "5", "6", "7" }));
        cboAccessBits0AKM1.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));

        lblAccessBits1AKM1.setFont(new java.awt.Font("Verdana", 0, 11)); // NOI18N
        lblAccessBits1AKM1.setText("Access Bits 1");

        cboAccessBits1AKM1.setFont(new java.awt.Font("Verdana", 1, 11)); // NOI18N
        cboAccessBits1AKM1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "0", "1", "2", "3", "4", "5", "6", "7" }));
        cboAccessBits1AKM1.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));

        lblAccessBits2AKM1.setFont(new java.awt.Font("Verdana", 0, 11)); // NOI18N
        lblAccessBits2AKM1.setText("Access Bits 2");

        cboAccessBits2AKM1.setFont(new java.awt.Font("Verdana", 1, 11)); // NOI18N
        cboAccessBits2AKM1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "0", "1", "2", "3", "4", "5", "6", "7" }));
        cboAccessBits2AKM1.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));

        lblTrailerAccessBitsAKM1.setFont(new java.awt.Font("Verdana", 0, 11)); // NOI18N
        lblTrailerAccessBitsAKM1.setText("Trailer Access Bits");

        cboTrailerAccessBitsAKM1.setFont(new java.awt.Font("Verdana", 1, 11)); // NOI18N
        cboTrailerAccessBitsAKM1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "0", "1", "2", "3", "4", "5", "6", "7" }));
        cboTrailerAccessBitsAKM1.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));

        lblTrailerByte9AKM1.setFont(new java.awt.Font("Verdana", 0, 11)); // NOI18N
        lblTrailerByte9AKM1.setText("Trailer Byte 9");

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

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

        javax.swing.GroupLayout tabSectorTrailerWriteAKM1Layout = new javax.swing.GroupLayout(tabSectorTrailerWriteAKM1);
        tabSectorTrailerWriteAKM1.setLayout(tabSectorTrailerWriteAKM1Layout);
        tabSectorTrailerWriteAKM1Layout.setHorizontalGroup(
            tabSectorTrailerWriteAKM1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(tabSectorTrailerWriteAKM1Layout.createSequentialGroup()
                .addGap(44, 44, 44)
                .addGroup(tabSectorTrailerWriteAKM1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lblAddressingModeAKM1)
                    .addComponent(lblBlockOrSectorAddressAKM1)
                    .addComponent(lblAccessBits0AKM1)
                    .addComponent(lblAccessBits1AKM1)
                    .addComponent(lblAccessBits2AKM1))
                .addGap(14, 14, 14)
                .addGroup(tabSectorTrailerWriteAKM1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(cboAccessBits2AKM1, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(cboAccessBits1AKM1, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(cboAccessBits0AKM1, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(txtBlockOrSectorAddressAKM1)
                    .addComponent(cboAddressingModeAKM1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(67, 67, 67)
                .addGroup(tabSectorTrailerWriteAKM1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(tabSectorTrailerWriteAKM1Layout.createSequentialGroup()
                        .addGroup(tabSectorTrailerWriteAKM1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lblTrailerAccessBitsAKM1)
                            .addComponent(lblTrailerByte9AKM1))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGroup(tabSectorTrailerWriteAKM1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(cboTrailerAccessBitsAKM1, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(txtTrailerByte9AKM1, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addComponent(btnSectorTrailerWriteAKM1, javax.swing.GroupLayout.PREFERRED_SIZE, 187, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(66, 66, 66))
        );
        tabSectorTrailerWriteAKM1Layout.setVerticalGroup(
            tabSectorTrailerWriteAKM1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(tabSectorTrailerWriteAKM1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(tabSectorTrailerWriteAKM1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(tabSectorTrailerWriteAKM1Layout.createSequentialGroup()
                        .addGroup(tabSectorTrailerWriteAKM1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(lblAddressingModeAKM1)
                            .addComponent(cboAddressingModeAKM1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(tabSectorTrailerWriteAKM1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(lblBlockOrSectorAddressAKM1, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(txtBlockOrSectorAddressAKM1, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(tabSectorTrailerWriteAKM1Layout.createSequentialGroup()
                        .addGroup(tabSectorTrailerWriteAKM1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(lblTrailerAccessBitsAKM1)
                            .addComponent(cboTrailerAccessBitsAKM1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(tabSectorTrailerWriteAKM1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(lblTrailerByte9AKM1, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(txtTrailerByte9AKM1, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(tabSectorTrailerWriteAKM1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(tabSectorTrailerWriteAKM1Layout.createSequentialGroup()
                        .addGap(1, 1, 1)
                        .addComponent(lblAccessBits0AKM1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(lblAccessBits1AKM1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(lblAccessBits2AKM1))
                    .addGroup(tabSectorTrailerWriteAKM1Layout.createSequentialGroup()
                        .addComponent(cboAccessBits0AKM1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(cboAccessBits1AKM1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(cboAccessBits2AKM1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(btnSectorTrailerWriteAKM1, javax.swing.GroupLayout.PREFERRED_SIZE, 77, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(19, Short.MAX_VALUE))
        );

        pgSectorTrailerWrite.addTab("SectorTrailer AKM1", tabSectorTrailerWriteAKM1);

        lblAddressingModeAKM2.setFont(new java.awt.Font("Verdana", 0, 11)); // NOI18N
        lblAddressingModeAKM2.setText("Addressing Mode");

        cboAddressingModeAKM2.setFont(new java.awt.Font("Verdana", 1, 11)); // NOI18N
        cboAddressingModeAKM2.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "0", "1" }));
        cboAddressingModeAKM2.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));

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

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

        lblAccessBits0AKM2.setFont(new java.awt.Font("Verdana", 0, 11)); // NOI18N
        lblAccessBits0AKM2.setText("Access Bits 0");

        cboAccessBits0AKM2.setFont(new java.awt.Font("Verdana", 1, 11)); // NOI18N
        cboAccessBits0AKM2.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "0", "1", "2", "3", "4", "5", "6", "7" }));
        cboAccessBits0AKM2.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));

        lblAccessBits1AKM2.setFont(new java.awt.Font("Verdana", 0, 11)); // NOI18N
        lblAccessBits1AKM2.setText("Access Bits 1");

        cboAccessBits1AKM2.setFont(new java.awt.Font("Verdana", 1, 11)); // NOI18N
        cboAccessBits1AKM2.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "0", "1", "2", "3", "4", "5", "6", "7" }));
        cboAccessBits1AKM2.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));

        lblAccessBits2AKM2.setFont(new java.awt.Font("Verdana", 0, 11)); // NOI18N
        lblAccessBits2AKM2.setText("Access Bits 2");

        cboAccessBits2AKM2.setFont(new java.awt.Font("Verdana", 1, 11)); // NOI18N
        cboAccessBits2AKM2.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "0", "1", "2", "3", "4", "5", "6", "7" }));
        cboAccessBits2AKM2.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));

        lblTrailerAccessBitsAKM2.setFont(new java.awt.Font("Verdana", 0, 11)); // NOI18N
        lblTrailerAccessBitsAKM2.setText("Trailer Access Bits");

        cboTrailerAccessBitsAKM2.setFont(new java.awt.Font("Verdana", 1, 11)); // NOI18N
        cboTrailerAccessBitsAKM2.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "0", "1", "2", "3", "4", "5", "6", "7" }));
        cboTrailerAccessBitsAKM2.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));

        lblTrailerByte9AKM2.setFont(new java.awt.Font("Verdana", 0, 11)); // NOI18N
        lblTrailerByte9AKM2.setText("Trailer Byte 9");

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

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

        javax.swing.GroupLayout tabSectorTrailerWriteAKM2Layout = new javax.swing.GroupLayout(tabSectorTrailerWriteAKM2);
        tabSectorTrailerWriteAKM2.setLayout(tabSectorTrailerWriteAKM2Layout);
        tabSectorTrailerWriteAKM2Layout.setHorizontalGroup(
            tabSectorTrailerWriteAKM2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(tabSectorTrailerWriteAKM2Layout.createSequentialGroup()
                .addGap(44, 44, 44)
                .addGroup(tabSectorTrailerWriteAKM2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lblAddressingModeAKM2)
                    .addComponent(lblBlockOrSectorAddressAKM2)
                    .addComponent(lblAccessBits0AKM2)
                    .addComponent(lblAccessBits1AKM2)
                    .addComponent(lblAccessBits2AKM2))
                .addGap(14, 14, 14)
                .addGroup(tabSectorTrailerWriteAKM2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(cboAccessBits2AKM2, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(cboAccessBits1AKM2, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(cboAccessBits0AKM2, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(txtBlockOrSectorAddressAKM2)
                    .addComponent(cboAddressingModeAKM2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(67, 67, 67)
                .addGroup(tabSectorTrailerWriteAKM2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(tabSectorTrailerWriteAKM2Layout.createSequentialGroup()
                        .addGroup(tabSectorTrailerWriteAKM2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lblTrailerAccessBitsAKM2)
                            .addComponent(lblTrailerByte9AKM2))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGroup(tabSectorTrailerWriteAKM2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(cboTrailerAccessBitsAKM2, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(txtTrailerByte9AKM2, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addComponent(btnSectorTrailerWriteAKM2, javax.swing.GroupLayout.PREFERRED_SIZE, 187, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(66, 66, 66))
        );
        tabSectorTrailerWriteAKM2Layout.setVerticalGroup(
            tabSectorTrailerWriteAKM2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(tabSectorTrailerWriteAKM2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(tabSectorTrailerWriteAKM2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(tabSectorTrailerWriteAKM2Layout.createSequentialGroup()
                        .addGroup(tabSectorTrailerWriteAKM2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(lblAddressingModeAKM2)
                            .addComponent(cboAddressingModeAKM2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(tabSectorTrailerWriteAKM2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(lblBlockOrSectorAddressAKM2, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(txtBlockOrSectorAddressAKM2, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(tabSectorTrailerWriteAKM2Layout.createSequentialGroup()
                        .addGroup(tabSectorTrailerWriteAKM2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(lblTrailerAccessBitsAKM2)
                            .addComponent(cboTrailerAccessBitsAKM2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(tabSectorTrailerWriteAKM2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(lblTrailerByte9AKM2, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(txtTrailerByte9AKM2, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(tabSectorTrailerWriteAKM2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(tabSectorTrailerWriteAKM2Layout.createSequentialGroup()
                        .addGap(1, 1, 1)
                        .addComponent(lblAccessBits0AKM2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(lblAccessBits1AKM2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(lblAccessBits2AKM2))
                    .addGroup(tabSectorTrailerWriteAKM2Layout.createSequentialGroup()
                        .addComponent(cboAccessBits0AKM2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(cboAccessBits1AKM2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(cboAccessBits2AKM2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(btnSectorTrailerWriteAKM2, javax.swing.GroupLayout.PREFERRED_SIZE, 77, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(19, Short.MAX_VALUE))
        );

        pgSectorTrailerWrite.addTab("SectorTrailer AKM2", tabSectorTrailerWriteAKM2);

        lblAddressingModePK.setFont(new java.awt.Font("Verdana", 0, 11)); // NOI18N
        lblAddressingModePK.setText("Addressing Mode");

        cboAddressingModePK.setFont(new java.awt.Font("Verdana", 1, 11)); // NOI18N
        cboAddressingModePK.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "0", "1" }));
        cboAddressingModePK.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));

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

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

        lblAccessBits0PK.setFont(new java.awt.Font("Verdana", 0, 11)); // NOI18N
        lblAccessBits0PK.setText("Access Bits 0");

        cboAccessBits0PK.setFont(new java.awt.Font("Verdana", 1, 11)); // NOI18N
        cboAccessBits0PK.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "0", "1", "2", "3", "4", "5", "6", "7" }));
        cboAccessBits0PK.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));

        lblAccessBits1PK.setFont(new java.awt.Font("Verdana", 0, 11)); // NOI18N
        lblAccessBits1PK.setText("Access Bits 1");

        cboAccessBits1PK.setFont(new java.awt.Font("Verdana", 1, 11)); // NOI18N
        cboAccessBits1PK.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "0", "1", "2", "3", "4", "5", "6", "7" }));
        cboAccessBits1PK.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));

        lblAccessBits2PK.setFont(new java.awt.Font("Verdana", 0, 11)); // NOI18N
        lblAccessBits2PK.setText("Access Bits 2");

        cboAccessBits2PK.setFont(new java.awt.Font("Verdana", 1, 11)); // NOI18N
        cboAccessBits2PK.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "0", "1", "2", "3", "4", "5", "6", "7" }));
        cboAccessBits2PK.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));

        lblTrailerAccessBitsPK.setFont(new java.awt.Font("Verdana", 0, 11)); // NOI18N
        lblTrailerAccessBitsPK.setText("Trailer Access Bits");

        cboTrailerAccessBitsPK.setFont(new java.awt.Font("Verdana", 1, 11)); // NOI18N
        cboTrailerAccessBitsPK.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "0", "1", "2", "3", "4", "5", "6", "7" }));
        cboTrailerAccessBitsPK.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));

        lblTrailerByte9PK.setFont(new java.awt.Font("Verdana", 0, 11)); // NOI18N
        lblTrailerByte9PK.setText("Trailer Byte 9");

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

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

        javax.swing.GroupLayout tabSectorTrailerWritePKLayout = new javax.swing.GroupLayout(tabSectorTrailerWritePK);
        tabSectorTrailerWritePK.setLayout(tabSectorTrailerWritePKLayout);
        tabSectorTrailerWritePKLayout.setHorizontalGroup(
            tabSectorTrailerWritePKLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(tabSectorTrailerWritePKLayout.createSequentialGroup()
                .addGap(44, 44, 44)
                .addGroup(tabSectorTrailerWritePKLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lblAddressingModePK)
                    .addComponent(lblBlockOrSectorAddressPK)
                    .addComponent(lblAccessBits0PK)
                    .addComponent(lblAccessBits1PK)
                    .addComponent(lblAccessBits2PK))
                .addGap(14, 14, 14)
                .addGroup(tabSectorTrailerWritePKLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(cboAccessBits2PK, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(cboAccessBits1PK, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(cboAccessBits0PK, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(txtBlockOrSectorAddressPK)
                    .addComponent(cboAddressingModePK, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(67, 67, 67)
                .addGroup(tabSectorTrailerWritePKLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(tabSectorTrailerWritePKLayout.createSequentialGroup()
                        .addGroup(tabSectorTrailerWritePKLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lblTrailerAccessBitsPK)
                            .addComponent(lblTrailerByte9PK))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGroup(tabSectorTrailerWritePKLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(cboTrailerAccessBitsPK, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(txtTrailerByte9PK, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addComponent(btnSectorTrailerWritePK, javax.swing.GroupLayout.PREFERRED_SIZE, 187, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(64, 64, 64))
        );
        tabSectorTrailerWritePKLayout.setVerticalGroup(
            tabSectorTrailerWritePKLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(tabSectorTrailerWritePKLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(tabSectorTrailerWritePKLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(tabSectorTrailerWritePKLayout.createSequentialGroup()
                        .addGroup(tabSectorTrailerWritePKLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(lblAddressingModePK)
                            .addComponent(cboAddressingModePK, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(tabSectorTrailerWritePKLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(lblBlockOrSectorAddressPK, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(txtBlockOrSectorAddressPK, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(tabSectorTrailerWritePKLayout.createSequentialGroup()
                        .addGroup(tabSectorTrailerWritePKLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(lblTrailerAccessBitsPK)
                            .addComponent(cboTrailerAccessBitsPK, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(tabSectorTrailerWritePKLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(lblTrailerByte9PK, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(txtTrailerByte9PK, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(tabSectorTrailerWritePKLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(tabSectorTrailerWritePKLayout.createSequentialGroup()
                        .addGap(1, 1, 1)
                        .addComponent(lblAccessBits0PK)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(lblAccessBits1PK)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(lblAccessBits2PK))
                    .addGroup(tabSectorTrailerWritePKLayout.createSequentialGroup()
                        .addComponent(cboAccessBits0PK, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(cboAccessBits1PK, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(cboAccessBits2PK, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(btnSectorTrailerWritePK, javax.swing.GroupLayout.PREFERRED_SIZE, 77, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(19, Short.MAX_VALUE))
        );

        pgSectorTrailerWrite.addTab("SectorTrailer PK", tabSectorTrailerWritePK);

        getContentPane().add(pgSectorTrailerWrite, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 140, 550, 191));

        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 void chkHexKeyAItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_chkHexKeyAItemStateChanged
        new Global().Check_box(pnlKeyA, "txtSectorKeyA", evt);
        new Global().HEX_BOX   = chkHexKeyA;
        new Global().TEXTFIELD = "txtSectorKeyA";
}//GEN-LAST:event_chkHexKeyAItemStateChanged

    private void chkHexKeyBItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_chkHexKeyBItemStateChanged
        new Global().Check_box(pnlKeyB, "txtSectorKeyB", evt);
        new Global().HEX_BOX   = chkHexKeyB;
        new Global().TEXTFIELD = "txtSectorKeyB";
}//GEN-LAST:event_chkHexKeyBItemStateChanged

    private void formInternalFrameActivated(javax.swing.event.InternalFrameEvent evt) {//GEN-FIRST:event_formInternalFrameActivated
        new Global().CreateKey(312, 5, 31, 29, "txtPKKey", pnlHeader);
        new Global().CreateKey(45, 45, 31, 29, "txtSectorKeyA", pnlKeyA);
        new Global().CreateKey(45, 45, 31, 29, "txtSectorKeyB", pnlKeyB);
    }//GEN-LAST:event_formInternalFrameActivated

    private void btnSectorTrailerWriteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSectorTrailerWriteActionPerformed
        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);                                                  
          byte key_index                  = (byte) cboKeyIndex.getSelectedIndex() ;
          byte addressing_mode            = 0;
          byte bBlockOrSectorAddress      = 0;
          byte block_access_bits0         = 0;
          byte block_access_bits1         = 0;
          byte block_access_bits2         = 0;
          byte sector_trailer_access_bits = 0;
          byte sector_trailer_byte9       = 0;
        
            if (txtBlockOrSectorAddress.getText().trim().isEmpty()) {
                JOptionPane.showMessageDialog(rootPane, "You must enter the  BLOCK ADDRESS !", "Warning !", JOptionPane.WARNING_MESSAGE);
                txtBlockOrSectorAddress.requestFocus();
                return;
            }
            if (txtTrailerByte9.getText().trim().isEmpty()) {
                JOptionPane.showMessageDialog(rootPane, "You must enter the  TRAILER BYTE 9 !", "Warning !", JOptionPane.WARNING_MESSAGE);
                txtTrailerByte9.requestFocus();
                return;
            }
            
            addressing_mode            = (byte) cboAddressingMode.getSelectedIndex();
            bBlockOrSectorAddress      = Byte.parseByte(txtBlockOrSectorAddress.getText());
            block_access_bits0         = (byte) cboAccessBits0.getSelectedIndex();
            block_access_bits1         = (byte) cboAccessBits1.getSelectedIndex();
            block_access_bits2         = (byte) cboAccessBits2.getSelectedIndex();
            sector_trailer_access_bits = (byte) cboTrailerAccessBits.getSelectedIndex();
            sector_trailer_byte9       = Byte.parseByte(txtTrailerByte9.getText());
            
            iFResult = Declarations.UFrDeclarations.UFRInstance.SectorTrailerWrite(addressing_mode, bBlockOrSectorAddress, new Global().KEY(pnlKeyA, "txtSectorKeyA", chkHexKeyA),block_access_bits0, block_access_bits1, block_access_bits2,sector_trailer_access_bits, sector_trailer_byte9, new Global().KEY(pnlKeyB, "txtSectorKeyB", chkHexKeyB),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 e) {
            JOptionPane.showMessageDialog(rootPane, APPROPRIATE_FORMAT, "Error !", JOptionPane.ERROR_MESSAGE);
        } finally {
            M.SetFunct(false);            
        }

    }//GEN-LAST:event_btnSectorTrailerWriteActionPerformed

    private void btnSectorTrailerWriteAKM1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSectorTrailerWriteAKM1ActionPerformed
        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);
          byte addressing_mode            = 0;
          byte bBlockOrSectorAddress      = 0;
          byte block_access_bits0         = 0;
          byte block_access_bits1         = 0;
          byte block_access_bits2         = 0;
          byte sector_trailer_access_bits = 0;
          byte sector_trailer_byte9       = 0;
        
            if (txtBlockOrSectorAddressAKM1.getText().trim().isEmpty()) {
                JOptionPane.showMessageDialog(rootPane, "You must enter the  BLOCK ADDRESS !", "Warning !", JOptionPane.WARNING_MESSAGE);
                txtBlockOrSectorAddressAKM1.requestFocus();
                return;
            }
            if (txtTrailerByte9AKM1.getText().trim().isEmpty()) {
                JOptionPane.showMessageDialog(rootPane, "You must enter the  TRAILER BYTE 9 !", "Warning !", JOptionPane.WARNING_MESSAGE);
                txtTrailerByte9AKM1.requestFocus();
                return;
            }

            addressing_mode            = (byte) cboAddressingModeAKM1.getSelectedIndex();
            bBlockOrSectorAddress      = Byte.parseByte(txtBlockOrSectorAddressAKM1.getText());
            block_access_bits0         = (byte) cboAccessBits0AKM1.getSelectedIndex();
            block_access_bits1         = (byte) cboAccessBits1AKM1.getSelectedIndex();
            block_access_bits2         = (byte) cboAccessBits2AKM1.getSelectedIndex();
            sector_trailer_access_bits = (byte) cboTrailerAccessBitsAKM1.getSelectedIndex();
            sector_trailer_byte9       = Byte.parseByte(txtTrailerByte9AKM1.getText());
            
            iFResult = Declarations.UFrDeclarations.UFRInstance.SectorTrailerWrite_AKM1(addressing_mode, bBlockOrSectorAddress, new Global().KEY(pnlKeyA, "txtSectorKeyA", chkHexKeyA),block_access_bits0, block_access_bits1, block_access_bits2,sector_trailer_access_bits, sector_trailer_byte9, new Global().KEY(pnlKeyB, "txtSectorKeyB", chkHexKeyB),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 e) {
            JOptionPane.showMessageDialog(rootPane, APPROPRIATE_FORMAT, "Error !", JOptionPane.ERROR_MESSAGE);
        } finally {
            M.SetFunct(false);            
        }
    }//GEN-LAST:event_btnSectorTrailerWriteAKM1ActionPerformed

    private void btnSectorTrailerWriteAKM2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSectorTrailerWriteAKM2ActionPerformed
        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);
          byte addressing_mode            = 0;
          byte bBlockOrSectorAddress      = 0;
          byte block_access_bits0         = 0;
          byte block_access_bits1         = 0;
          byte block_access_bits2         = 0;
          byte sector_trailer_access_bits = 0;
          byte sector_trailer_byte9       = 0;
        
            if (txtBlockOrSectorAddressAKM2.getText().trim().isEmpty()) {
                JOptionPane.showMessageDialog(rootPane, "You must enter the  BLOCK ADDRESS !", "Warning !", JOptionPane.WARNING_MESSAGE);
                txtBlockOrSectorAddressAKM2.requestFocus();
                return;
            }
            if (txtTrailerByte9AKM2.getText().trim().isEmpty()) {
                JOptionPane.showMessageDialog(rootPane, "You must enter the  TRAILER BYTE 9 !", "Warning !", JOptionPane.WARNING_MESSAGE);
                txtTrailerByte9AKM2.requestFocus();
                return;
            }

            
            addressing_mode            = (byte) cboAddressingModeAKM2.getSelectedIndex();
            bBlockOrSectorAddress      = Byte.parseByte(txtBlockOrSectorAddressAKM2.getText());
            block_access_bits0         = (byte) cboAccessBits0AKM2.getSelectedIndex();
            block_access_bits1         = (byte) cboAccessBits1AKM2.getSelectedIndex();
            block_access_bits2         = (byte) cboAccessBits2AKM2.getSelectedIndex();
            sector_trailer_access_bits = (byte) cboTrailerAccessBitsAKM2.getSelectedIndex();
            sector_trailer_byte9       = Byte.parseByte(txtTrailerByte9AKM2.getText());
            
            iFResult = Declarations.UFrDeclarations.UFRInstance.SectorTrailerWrite_AKM2(addressing_mode, bBlockOrSectorAddress, new Global().KEY(pnlKeyA, "txtSectorKeyA", chkHexKeyA),block_access_bits0, block_access_bits1, block_access_bits2,sector_trailer_access_bits, sector_trailer_byte9, new Global().KEY(pnlKeyB, "txtSectorKeyB", chkHexKeyB),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 e) {
            JOptionPane.showMessageDialog(rootPane, APPROPRIATE_FORMAT, "Error !", JOptionPane.ERROR_MESSAGE);
        } finally {
            M.SetFunct(false);            
        }
    }//GEN-LAST:event_btnSectorTrailerWriteAKM2ActionPerformed

    private void btnSectorTrailerWritePKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSectorTrailerWritePKActionPerformed
        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);
          byte addressing_mode            = 0;
          byte bBlockOrSectorAddress      = 0;
          byte block_access_bits0         = 0;
          byte block_access_bits1         = 0;
          byte block_access_bits2         = 0;
          byte sector_trailer_access_bits = 0;
          byte sector_trailer_byte9       = 0;
          
            if (txtBlockOrSectorAddressPK.getText().trim().isEmpty()) {
                JOptionPane.showMessageDialog(rootPane, "You must enter the  BLOCK ADDRESS !", "Warning !", JOptionPane.WARNING_MESSAGE);
                txtBlockOrSectorAddressPK.requestFocus();
                return;
            }
            if (txtTrailerByte9PK.getText().trim().isEmpty()) {
                JOptionPane.showMessageDialog(rootPane, "You must enter the  TRAILER BYTE 9 !", "Warning !", JOptionPane.WARNING_MESSAGE);
                txtTrailerByte9PK.requestFocus();
                return;
            }

            
            addressing_mode            = (byte) cboAddressingModePK.getSelectedIndex();
            bBlockOrSectorAddress      = Byte.parseByte(txtBlockOrSectorAddressPK.getText());
            block_access_bits0         = (byte) cboAccessBits0PK.getSelectedIndex();
            block_access_bits1         = (byte) cboAccessBits1PK.getSelectedIndex();
            block_access_bits2         = (byte) cboAccessBits2PK.getSelectedIndex();
            sector_trailer_access_bits = (byte) cboTrailerAccessBitsPK.getSelectedIndex();
            sector_trailer_byte9       = Byte.parseByte(txtTrailerByte9PK.getText());
            
            iFResult = Declarations.UFrDeclarations.UFRInstance.SectorTrailerWrite_PK(addressing_mode, bBlockOrSectorAddress, new Global().KEY(pnlKeyA, "txtSectorKeyA", chkHexKeyA),block_access_bits0, block_access_bits1, block_access_bits2,sector_trailer_access_bits, sector_trailer_byte9, new Global().KEY(pnlKeyB, "txtSectorKeyB", chkHexKeyB),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 e) {
            JOptionPane.showMessageDialog(rootPane, APPROPRIATE_FORMAT, "Error !", JOptionPane.ERROR_MESSAGE);
        } finally {
            M.SetFunct(false);            
        }
    }//GEN-LAST:event_btnSectorTrailerWritePKActionPerformed
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnSectorTrailerWrite;
    private javax.swing.JButton btnSectorTrailerWriteAKM1;
    private javax.swing.JButton btnSectorTrailerWriteAKM2;
    private javax.swing.JButton btnSectorTrailerWritePK;
    private javax.swing.ButtonGroup btngAUTH1AB;
    private javax.swing.JComboBox cboAccessBits0;
    private javax.swing.JComboBox cboAccessBits0AKM1;
    private javax.swing.JComboBox cboAccessBits0AKM2;
    private javax.swing.JComboBox cboAccessBits0PK;
    private javax.swing.JComboBox cboAccessBits1;
    private javax.swing.JComboBox cboAccessBits1AKM1;
    private javax.swing.JComboBox cboAccessBits1AKM2;
    private javax.swing.JComboBox cboAccessBits1PK;
    private javax.swing.JComboBox cboAccessBits2;
    private javax.swing.JComboBox cboAccessBits2AKM1;
    private javax.swing.JComboBox cboAccessBits2AKM2;
    private javax.swing.JComboBox cboAccessBits2PK;
    private javax.swing.JComboBox cboAddressingMode;
    private javax.swing.JComboBox cboAddressingModeAKM1;
    private javax.swing.JComboBox cboAddressingModeAKM2;
    private javax.swing.JComboBox cboAddressingModePK;
    private javax.swing.JComboBox cboKeyIndex;
    private javax.swing.JComboBox cboTrailerAccessBits;
    private javax.swing.JComboBox cboTrailerAccessBitsAKM1;
    private javax.swing.JComboBox cboTrailerAccessBitsAKM2;
    private javax.swing.JComboBox cboTrailerAccessBitsPK;
    private javax.swing.JCheckBox chkHexKeyA;
    private javax.swing.JCheckBox chkHexKeyB;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel lblAccessBits0;
    private javax.swing.JLabel lblAccessBits0AKM1;
    private javax.swing.JLabel lblAccessBits0AKM2;
    private javax.swing.JLabel lblAccessBits0PK;
    private javax.swing.JLabel lblAccessBits1;
    private javax.swing.JLabel lblAccessBits1AKM1;
    private javax.swing.JLabel lblAccessBits1AKM2;
    private javax.swing.JLabel lblAccessBits1PK;
    private javax.swing.JLabel lblAccessBits2;
    private javax.swing.JLabel lblAccessBits2AKM1;
    private javax.swing.JLabel lblAccessBits2AKM2;
    private javax.swing.JLabel lblAccessBits2PK;
    private javax.swing.JLabel lblAddressingMode;
    private javax.swing.JLabel lblAddressingModeAKM1;
    private javax.swing.JLabel lblAddressingModeAKM2;
    private javax.swing.JLabel lblAddressingModePK;
    private javax.swing.JLabel lblBlockOrSectorAddress;
    private javax.swing.JLabel lblBlockOrSectorAddressAKM1;
    private javax.swing.JLabel lblBlockOrSectorAddressAKM2;
    private javax.swing.JLabel lblBlockOrSectorAddressPK;
    private javax.swing.JTextField lblFunction;
    private javax.swing.JLabel lblKeyA;
    private javax.swing.JLabel lblKeyB;
    private javax.swing.JLabel lblKeyIndex;
    private javax.swing.JLabel lblTrailerAccessBits;
    private javax.swing.JLabel lblTrailerAccessBitsAKM1;
    private javax.swing.JLabel lblTrailerAccessBitsAKM2;
    private javax.swing.JLabel lblTrailerAccessBitsPK;
    private javax.swing.JLabel lblTrailerByte9;
    private javax.swing.JLabel lblTrailerByte9AKM1;
    private javax.swing.JLabel lblTrailerByte9AKM2;
    private javax.swing.JLabel lblTrailerByte9PK;
    private javax.swing.JTabbedPane pgSectorTrailerWrite;
    private javax.swing.JPanel pnlHeader;
    private javax.swing.JPanel pnlKeyA;
    private javax.swing.JPanel pnlKeyAB;
    private javax.swing.JPanel pnlKeyB;
    private javax.swing.JRadioButton rbAUTH1A;
    private javax.swing.JRadioButton rbAUTH1B;
    private javax.swing.JPanel tabSectorTrailerWrite;
    private javax.swing.JPanel tabSectorTrailerWriteAKM1;
    private javax.swing.JPanel tabSectorTrailerWriteAKM2;
    private javax.swing.JPanel tabSectorTrailerWritePK;
    private javax.swing.JTextField txtBlockOrSectorAddress;
    private javax.swing.JTextField txtBlockOrSectorAddressAKM1;
    private javax.swing.JTextField txtBlockOrSectorAddressAKM2;
    private javax.swing.JTextField txtBlockOrSectorAddressPK;
    private javax.swing.JTextField txtFErrorCode;
    private javax.swing.JTextField txtFErrorExplain;
    private javax.swing.JTextField txtTrailerByte9;
    private javax.swing.JTextField txtTrailerByte9AKM1;
    private javax.swing.JTextField txtTrailerByte9AKM2;
    private javax.swing.JTextField txtTrailerByte9PK;
    // End of variables declaration//GEN-END:variables
}
