×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Java
Posted by: Hendrawan Kuncoro
Added: Feb 24, 2012 3:40 AM
Views: 1599
Tags: no tags
  1.  
  2. import java.awt.Color;
  3. import java.awt.event.KeyEvent;
  4. import javax.print.attribute.AttributeSet;
  5. import javax.swing.JOptionPane;
  6. import javax.swing.text.BadLocationException;
  7. import javax.swing.text.PlainDocument;
  8.  
  9. /*
  10.  * To change this template, choose Tools | Templates
  11.  * and open the template in the editor.
  12.  */
  13.  
  14. /*
  15.  * NopelIdpel.java
  16.  *
  17.  * Created on Feb 16, 2012, 8:53:48 AM
  18.  */
  19. /**
  20.  *
  21.  * @author Admin
  22.  */
  23. public class NopelIdpel extends javax.swing.JFrame {
  24.  
  25.     /** Creates new form NopelIdpel */
  26.     public NopelIdpel() {
  27.         initComponents();
  28.         //txtNopel.setDocument(new batasiInput((byte)9).getFilter());
  29.         this.setLocationRelativeTo(null);
  30.     }
  31.  
  32.     /** This method is called from within the constructor to
  33.      * initialize the form.
  34.      * WARNING: Do NOT modify this code. The content of this method is
  35.      * always regenerated by the Form Editor.
  36.      */
  37.     @SuppressWarnings("unchecked")
  38.     // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  39.     private void initComponents() {
  40.  
  41.         jTextField1 = new javax.swing.JTextField();
  42.         buttonGroup1 = new javax.swing.ButtonGroup();
  43.         buttonGroup2 = new javax.swing.ButtonGroup();
  44.         lblJudul = new javax.swing.JLabel();
  45.         lblNopel = new javax.swing.JLabel();
  46.         lblIdpel = new javax.swing.JLabel();
  47.         txtNopel = new javax.swing.JTextField();
  48.         txtIdpel = new javax.swing.JTextField();
  49.         btnConvert = new javax.swing.JButton();
  50.         btnClear = new javax.swing.JButton();
  51.         btnClose = new javax.swing.JButton();
  52.         pnlColor = new javax.swing.JPanel();
  53.         cbRed = new javax.swing.JCheckBox();
  54.         cbBlue = new javax.swing.JCheckBox();
  55.         cbGray = new javax.swing.JCheckBox();
  56.         pnlKonversi = new javax.swing.JPanel();
  57.         rbtNopel = new javax.swing.JRadioButton();
  58.         rbtIdpel = new javax.swing.JRadioButton();
  59.         jSeparator1 = new javax.swing.JSeparator();
  60.         lblFormatNopel = new javax.swing.JLabel();
  61.         lblFormatIdpel = new javax.swing.JLabel();
  62.  
  63.         jTextField1.setText("jTextField1");
  64.  
  65.         setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
  66.  
  67.         lblJudul.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
  68.         lblJudul.setText("KONVERSI NOPEL KE IDPEL");
  69.  
  70.         lblNopel.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
  71.         lblNopel.setText("NOPEL");
  72.  
  73.         lblIdpel.setFont(new java.awt.Font("Tahoma", 1, 14));
  74.         lblIdpel.setText("IDPEL");
  75.  
  76.         txtNopel.setToolTipText("");
  77.         txtNopel.addActionListener(new java.awt.event.ActionListener() {
  78.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  79.                 txtNopelActionPerformed(evt);
  80.             }
  81.            
  82.         });
  83.         txtNopel.addKeyListener(new java.awt.event.KeyListener(){
  84.                 public void keyTyped(KeyEvent e) {
  85.             }
  86.                 public void keyPressed(KeyEvent e) {
  87.             }
  88.                 public void keyReleased(KeyEvent e) {
  89.                         int banyakKarakter = txtNopel.getText().length();
  90.                    
  91.                         if(banyakKarakter != 8){
  92.                                 btnConvert.setEnabled(false);
  93.                     }else {
  94.                        
  95.                         //Check character combination
  96.                         boolean isValidNopel = false;
  97.                         boolean isValidFirstLetter = false;
  98.                         boolean isValidSecondLetter = false;
  99.                         boolean isValidNumber = false;
  100.                         String nopel = txtNopel.getText();
  101.                         String allowableFirstLetter [] = {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"};
  102.                         String allowableSecondLetter [] = {"B", "C", "D", "E", "F", "G", "H", "K", "M", "N", "P", "R"};
  103.                        
  104.                         //check first letter
  105.                         try {
  106.                                 //try convert to integer
  107.                                 Integer.parseInt(nopel.substring(0, 1));
  108.                                 isValidFirstLetter = false;
  109.                                
  110.                                         } catch (NumberFormatException NFE) {
  111.                                                 //then its string
  112.                                                 for (int i = 0; i < allowableFirstLetter.length; i++) {
  113.                                                         if (allowableFirstLetter[i].compareToIgnoreCase(nopel.substring(0, 1)) == 0) {
  114.                                                                 isValidFirstLetter = true;
  115.                                                                 break;
  116.                                                         }
  117.                                                 }
  118.                                         }
  119.                        
  120.                         //just check the second letter if first letter is valid
  121.                         if (isValidFirstLetter) {
  122.                                 //check second letter
  123.                                 try {
  124.                                         //try convert to integer
  125.                                         Integer.parseInt(nopel.substring(1, 2));
  126.                                         isValidSecondLetter = false;
  127.                                        
  128.                                                 } catch (NumberFormatException NFE) {
  129.                                                         //then its string
  130.                                                         for (int i = 0; i < allowableSecondLetter.length; i++) {
  131.                                                                 if (allowableSecondLetter[i].compareToIgnoreCase(nopel.substring(1, 2)) == 0) {
  132.                                                                         isValidSecondLetter = true;
  133.                                                                         break;
  134.                                                                 }
  135.                                                         }
  136.                                                 }
  137.                                
  138.                                 //just check rest number if second letter is valid
  139.                                 if (isValidSecondLetter) {
  140.                                         for (int i = 2; i< 8; i ++) {
  141.                                                 //check rest is number
  142.                                         try {
  143.                                                 //try convert to integer
  144.                                                 Integer.parseInt(nopel.substring(i, i+1));
  145.                                                 isValidNumber = true;
  146.                                                                
  147.                                                         } catch (NumberFormatException NFE) {
  148.                                                                 //then its string
  149.                                                                 isValidNumber = false;
  150.                                                                 break;
  151.                                                         }
  152.                                         }
  153.                                 }
  154.                         }
  155.                        
  156.                         //build valid for nopel
  157.                         isValidNopel = isValidFirstLetter && isValidSecondLetter && isValidNumber;
  158.                                
  159.                                 if(isValidNopel)
  160.                                         btnConvert.setEnabled(true);
  161.                        
  162.                     }
  163.             }
  164.         });
  165.  
  166.         //disable the button convert first, before input
  167.         btnConvert.setEnabled(false);
  168.        
  169.         btnConvert.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
  170.         btnConvert.setText("CONVERT");
  171.         btnConvert.addActionListener(new java.awt.event.ActionListener() {
  172.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  173.                 btnConvertActionPerformed(evt);
  174.             }
  175.         });
  176.  
  177.         btnClear.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
  178.         btnClear.setText("CLEAR");
  179.         btnClear.addActionListener(new java.awt.event.ActionListener() {
  180.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  181.                 btnClearActionPerformed(evt);
  182.             }
  183.         });
  184.  
  185.         btnClose.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
  186.         btnClose.setText("CLOSE");
  187.         btnClose.addActionListener(new java.awt.event.ActionListener() {
  188.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  189.                 btnCloseActionPerformed(evt);
  190.             }
  191.         });
  192.  
  193.         buttonGroup1.add(cbRed);
  194.         cbRed.setText("Red");
  195.         cbRed.addActionListener(new java.awt.event.ActionListener() {
  196.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  197.                 cbRedActionPerformed(evt);
  198.             }
  199.         });
  200.  
  201.         buttonGroup1.add(cbBlue);
  202.         cbBlue.setText("White");
  203.         cbBlue.addActionListener(new java.awt.event.ActionListener() {
  204.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  205.                 cbBlueActionPerformed(evt);
  206.             }
  207.         });
  208.  
  209.         buttonGroup1.add(cbGray);
  210.         cbGray.setText("Gray");
  211.         cbGray.addActionListener(new java.awt.event.ActionListener() {
  212.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  213.                 cbGrayActionPerformed(evt);
  214.             }
  215.         });
  216.  
  217.         javax.swing.GroupLayout pnlColorLayout = new javax.swing.GroupLayout(pnlColor);
  218.         pnlColor.setLayout(pnlColorLayout);
  219.         pnlColorLayout.setHorizontalGroup(
  220.             pnlColorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  221.             .addGroup(pnlColorLayout.createSequentialGroup()
  222.                 .addContainerGap()
  223.                 .addGroup(pnlColorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  224.                     .addComponent(cbBlue)
  225.                     .addComponent(cbGray)
  226.                     .addComponent(cbRed))
  227.                 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
  228.         );
  229.         pnlColorLayout.setVerticalGroup(
  230.             pnlColorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  231.             .addGroup(pnlColorLayout.createSequentialGroup()
  232.                 .addGap(10, 10, 10)
  233.                 .addComponent(cbRed)
  234.                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  235.                 .addComponent(cbBlue, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
  236.                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  237.                 .addComponent(cbGray)
  238.                 .addContainerGap(21, Short.MAX_VALUE))
  239.         );
  240.  
  241.         buttonGroup2.add(rbtNopel);
  242.         rbtNopel.setText("Konversi Nopel");
  243.         rbtNopel.addActionListener(new java.awt.event.ActionListener() {
  244.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  245.                 rbtNopelActionPerformed(evt);
  246.             }
  247.         });
  248.  
  249.         buttonGroup2.add(rbtIdpel);
  250.         rbtIdpel.setText("Konversi Idpel");
  251.         rbtIdpel.addActionListener(new java.awt.event.ActionListener() {
  252.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  253.                 rbtIdpelActionPerformed(evt);
  254.             }
  255.         });
  256.  
  257.         javax.swing.GroupLayout pnlKonversiLayout = new javax.swing.GroupLayout(pnlKonversi);
  258.         pnlKonversi.setLayout(pnlKonversiLayout);
  259.         pnlKonversiLayout.setHorizontalGroup(
  260.             pnlKonversiLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  261.             .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnlKonversiLayout.createSequentialGroup()
  262.                 .addComponent(rbtNopel)
  263.                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 3, Short.MAX_VALUE)
  264.                 .addComponent(rbtIdpel)
  265.                 .addContainerGap())
  266.         );
  267.         pnlKonversiLayout.setVerticalGroup(
  268.             pnlKonversiLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  269.             .addGroup(pnlKonversiLayout.createSequentialGroup()
  270.                 .addContainerGap()
  271.                 .addGroup(pnlKonversiLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  272.                     .addComponent(rbtIdpel)
  273.                     .addComponent(rbtNopel))
  274.                 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
  275.         );
  276.  
  277.         lblFormatNopel.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N
  278.         lblFormatNopel.setForeground(new java.awt.Color(51, 51, 51));
  279.         lblFormatNopel.setText("mis: CN0622067");
  280.  
  281.         lblFormatIdpel.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N
  282.         lblFormatIdpel.setForeground(new java.awt.Color(51, 51, 51));
  283.         lblFormatIdpel.setText("mis: 513010285649");
  284.  
  285.         javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
  286.         getContentPane().setLayout(layout);
  287.         layout.setHorizontalGroup(
  288.             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  289.             .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
  290.                 .addGap(83, 83, 83)
  291.                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
  292.                     .addGroup(layout.createSequentialGroup()
  293.                         .addComponent(btnClear)
  294.                         .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  295.                         .addComponent(btnConvert, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE)
  296.                         .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  297.                         .addComponent(btnClose, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE))
  298.                     .addGroup(layout.createSequentialGroup()
  299.                         .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  300.                             .addComponent(lblNopel, javax.swing.GroupLayout.PREFERRED_SIZE, 62, javax.swing.GroupLayout.PREFERRED_SIZE)
  301.                             .addComponent(lblIdpel))
  302.                         .addGap(18, 18, 18)
  303.                         .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
  304.                             .addGroup(layout.createSequentialGroup()
  305.                                 .addGap(2, 2, 2)
  306.                                 .addComponent(lblFormatNopel, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE))
  307.                             .addGroup(layout.createSequentialGroup()
  308.                                 .addGap(2, 2, 2)
  309.                                 .addComponent(lblFormatIdpel, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE))
  310.                             .addComponent(txtIdpel)
  311.                             .addComponent(txtNopel)
  312.                             .addComponent(jSeparator1, javax.swing.GroupLayout.DEFAULT_SIZE, 280, Short.MAX_VALUE))))
  313.                 .addGap(30, 30, 30)
  314.                 .addComponent(pnlColor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  315.                 .addGap(73, 73, 73))
  316.             .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
  317.                 .addContainerGap()
  318.                 .addComponent(lblJudul)
  319.                 .addGap(181, 181, 181))
  320.             .addGroup(layout.createSequentialGroup()
  321.                 .addGap(202, 202, 202)
  322.                 .addComponent(pnlKonversi, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  323.                 .addGap(210, 210, 210))
  324.         );
  325.         layout.setVerticalGroup(
  326.             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  327.             .addGroup(layout.createSequentialGroup()
  328.                 .addContainerGap()
  329.                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  330.                     .addGroup(layout.createSequentialGroup()
  331.                         .addComponent(lblJudul)
  332.                         .addGap(19, 19, 19)
  333.                         .addComponent(pnlKonversi, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  334.                         .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  335.                         .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
  336.                         .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  337.                         .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  338.                             .addComponent(txtNopel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  339.                             .addComponent(lblNopel))
  340.                         .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  341.                         .addComponent(lblFormatNopel)
  342.                         .addGap(18, 18, 18)
  343.                         .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  344.                             .addComponent(txtIdpel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  345.                             .addComponent(lblIdpel))
  346.                         .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  347.                         .addComponent(lblFormatIdpel)
  348.                         .addGap(34, 34, 34)
  349.                         .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  350.                             .addComponent(btnConvert)
  351.                             .addComponent(btnClear)
  352.                             .addComponent(btnClose))
  353.                         .addGap(26, 26, 26))
  354.                     .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
  355.                         .addComponent(pnlColor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  356.                         .addGap(83, 83, 83))))
  357.         );
  358.  
  359.         pack();
  360.     }// </editor-fold>//GEN-END:initComponents
  361. //private void txtNopelKeyPressed(java.awt.event.KeyEvent evt) {                                      
  362. //        // TODO add your handling code here:
  363. //        int nilai_enter=evt.VK_ENTER;
  364. //        int kode=evt.getKeyCode();
  365. //        if (kode==nilai_enter){
  366. //            JOptionPane.showMessageDialog(null, "Anda telah menekan tombol ENTER untuk memproses...");
  367. //        }
  368. //    }      
  369.    
  370.    
  371. private void txtNopelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtNopelActionPerformed
  372. // TODO add your handling code here:
  373. }//GEN-LAST:event_txtNopelActionPerformed
  374.  
  375. //private void batasiKarakter(){
  376. //    int banyakKarakter=txtNopel.getText().length();
  377. //    if(banyakKarakter<9){
  378. //        JOptionPane.showMessageDialog(null, "Karakter yang Anda masukkan kurang dari 9 karakter");
  379. //        txtNopel.setText("");
  380. //    }
  381. //    else if (banyakKarakter>9){
  382. //        JOptionPane.showMessageDialog(null, "Karakter yang Anda masukkan melebihi dari 9 karakter");
  383. //        txtNopel.setText("");
  384. //    }
  385. //}
  386.  
  387. private void btnConvertActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnConvertActionPerformed
  388. // TODO add your handling code here:
  389. //    batasiKarakter();
  390.     Nopel nopelConverter = new Nopel(txtNopel.getText());
  391.     nopelConverter.convert();
  392.     txtIdpel.setText(nopelConverter.getIdPel());
  393.    
  394. }//GEN-LAST:event_btnConvertActionPerformed
  395.  
  396. private void btnClearActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnClearActionPerformed
  397. // TODO add your handling code here:
  398.     txtNopel.setText("");
  399.     txtIdpel.setText("");
  400. }//GEN-LAST:event_btnClearActionPerformed
  401.  
  402. private void btnCloseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCloseActionPerformed
  403. // TODO add your handling code here:
  404.     System.exit(0);
  405. }//GEN-LAST:event_btnCloseActionPerformed
  406.  
  407. private void cbBlueActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbBlueActionPerformed
  408. // TODO add your handling code here:
  409. this.getContentPane().setBackground(Color.WHITE);
  410. }//GEN-LAST:event_cbBlueActionPerformed
  411.  
  412. private void cbGrayActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbGrayActionPerformed
  413. // TODO add your handling code here:
  414. this.getContentPane().setBackground(Color.LIGHT_GRAY);
  415. }//GEN-LAST:event_cbGrayActionPerformed
  416.  
  417. private void cbRedActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbRedActionPerformed
  418. // TODO add your handling code here:
  419. this.getContentPane().setBackground(Color.CYAN);
  420. }//GEN-LAST:event_cbRedActionPerformed
  421.  
  422. private void rbtIdpelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rbtIdpelActionPerformed
  423. // TODO add your handling code here:
  424. txtNopel.setEnabled(false);
  425. txtIdpel.setEnabled(true);
  426. lblFormatIdpel.setEnabled(true);
  427. lblFormatNopel.setEnabled(false);
  428. txtIdpel.setText("");
  429. }//GEN-LAST:event_rbtIdpelActionPerformed
  430.  
  431. private void rbtNopelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rbtNopelActionPerformed
  432. // TODO add your handling code here:
  433. txtIdpel.setEnabled(false);
  434. txtNopel.setEnabled(true);
  435. lblFormatNopel.setEnabled(true);
  436. lblFormatIdpel.setEnabled(false);
  437. txtNopel.setText("");
  438. }//GEN-LAST:event_rbtNopelActionPerformed
  439.  
  440.     /**
  441.      * @param args the command line arguments
  442.      */
  443.     public static void main(String args[]) {
  444.         /* Set the Nimbus look and feel */
  445.         //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
  446.         /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
  447.          * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
  448.          */
  449.         try {
  450.             for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
  451.                 if ("Nimbus".equals(info.getName())) {
  452.                     javax.swing.UIManager.setLookAndFeel(info.getClassName());
  453.                     break;
  454.                 }
  455.             }
  456.         } catch (ClassNotFoundException ex) {
  457.             java.util.logging.Logger.getLogger(NopelIdpel.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  458.         } catch (InstantiationException ex) {
  459.             java.util.logging.Logger.getLogger(NopelIdpel.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  460.         } catch (IllegalAccessException ex) {
  461.             java.util.logging.Logger.getLogger(NopelIdpel.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  462.         } catch (javax.swing.UnsupportedLookAndFeelException ex) {
  463.             java.util.logging.Logger.getLogger(NopelIdpel.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  464.         }
  465.         //</editor-fold>
  466.  
  467.         /* Create and display the form */
  468.         java.awt.EventQueue.invokeLater(new Runnable() {
  469.  
  470.             public void run() {
  471.                 new NopelIdpel().setVisible(true);
  472.             }
  473.         });
  474.     }
  475.     // Variables declaration - do not modify//GEN-BEGIN:variables
  476.     private javax.swing.JButton btnClear;
  477.     private javax.swing.JButton btnClose;
  478.     private javax.swing.JButton btnConvert;
  479.     private javax.swing.ButtonGroup buttonGroup1;
  480.     private javax.swing.ButtonGroup buttonGroup2;
  481.     private javax.swing.JCheckBox cbBlue;
  482.     private javax.swing.JCheckBox cbGray;
  483.     private javax.swing.JCheckBox cbRed;
  484.     private javax.swing.JSeparator jSeparator1;
  485.     private javax.swing.JTextField jTextField1;
  486.     private javax.swing.JLabel lblFormatIdpel;
  487.     private javax.swing.JLabel lblFormatNopel;
  488.     private javax.swing.JLabel lblIdpel;
  489.     private javax.swing.JLabel lblJudul;
  490.     private javax.swing.JLabel lblNopel;
  491.     private javax.swing.JPanel pnlColor;
  492.     private javax.swing.JPanel pnlKonversi;
  493.     private javax.swing.JRadioButton rbtIdpel;
  494.     private javax.swing.JRadioButton rbtNopel;
  495.     private javax.swing.JTextField txtIdpel;
  496.     private javax.swing.JTextField txtNopel;
  497.     // End of variables declaration//GEN-END:variables
  498.  
  499. //    class batasiInput{
  500. //        byte length;
  501. //        PlainDocument filter;
  502. //        public batasiInput(byte length){
  503. //            this.length=length;
  504. //        }
  505. //        public PlainDocument getFilter(){
  506. //            filter=new PlainDocument(){
  507. //                public void insertString(int offs, String str,AttributeSet a) throws BadLocationException{
  508. //                    int ab=txtNopel.getText().length();
  509. //                    if(ab<length){
  510. //                        //super.insertString(offs, str, null);
  511. //                        super.insertString(offs, str, a);
  512. //                    }
  513. //                }
  514. //            };
  515. //            return filter;
  516. //        }
  517. //    }
  518. }
  519.