cursosr

Blogger Widgets

Senin, 06 Juli 2015

Biodata Mahasiswa Menggunakan Java




import javax.swing.ButtonGroup;
import javax.swing.JOptionPane;
public class biodata extends javax.swing.JFrame {
private ButtonGroup gabung;
   
    public biodata() {
        super("Biodata Mahasiswa");
        initComponents();
         gabung=new ButtonGroup();
         gabung.add(RbLakilaki);
           gabung.add(RbPerempuan);

        
    }

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

        jLabel1 = new javax.swing.JLabel();
        lblNPM = new javax.swing.JLabel();
        tfNPM = new javax.swing.JTextField();
        RbLakilaki = new javax.swing.JRadioButton();
        lbljeniskelamin = new javax.swing.JLabel();
        RbPerempuan = new javax.swing.JRadioButton();
        lbljurusan = new javax.swing.JLabel();
        btnSimpan = new javax.swing.JButton();
        btbBatal = new javax.swing.JButton();
        Cbjurusan = new javax.swing.JComboBox();
        jLabel5 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        output = new javax.swing.JTextArea();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setBackground(new java.awt.Color(0, 255, 102));
        setFont(new java.awt.Font("Times New Roman", 0, 14));

        jLabel1.setFont(new java.awt.Font("Times New Roman", 1, 18));
        jLabel1.setText("Biodata Mahasiswa");

        lblNPM.setFont(new java.awt.Font("Times New Roman", 0, 14));
        lblNPM.setText("NPM:");

        tfNPM.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tfNPMActionPerformed(evt);
            }
        });

        RbLakilaki.setFont(new java.awt.Font("Times New Roman", 0, 14));
        RbLakilaki.setText("Laki-laki");
        RbLakilaki.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                RbLakilakiActionPerformed(evt);
            }
        });

        lbljeniskelamin.setFont(new java.awt.Font("Times New Roman", 0, 14));
        lbljeniskelamin.setText("Jenis Kelamin:");

        RbPerempuan.setFont(new java.awt.Font("Times New Roman", 0, 14));
        RbPerempuan.setText("Perempuan");

        lbljurusan.setFont(new java.awt.Font("Times New Roman", 0, 14));
        lbljurusan.setText("Jurusan:");

        btnSimpan.setFont(new java.awt.Font("Times New Roman", 0, 14));
        btnSimpan.setText("Simpan");
        btnSimpan.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSimpanActionPerformed(evt);
            }
        });

        btbBatal.setFont(new java.awt.Font("Times New Roman", 0, 14));
        btbBatal.setText("Batal");
        btbBatal.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btbBatalActionPerformed(evt);
            }
        });

        Cbjurusan.setFont(new java.awt.Font("Times New Roman", 0, 14));
        Cbjurusan.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Manajemen Informatika", "Akuntansi", "Teknik Jaringan" }));

        jLabel5.setFont(new java.awt.Font("Times New Roman", 1, 14));
        jLabel5.setText("Terima kasih telah mengisi form ini");

        output.setColumns(20);
        output.setFont(new java.awt.Font("Times New Roman", 0, 14));
        output.setRows(5);
        jScrollPane1.setViewportView(output);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(lbljurusan))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lbljeniskelamin)
                            .addComponent(lblNPM))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(tfNPM, javax.swing.GroupLayout.DEFAULT_SIZE, 201, Short.MAX_VALUE)
                            .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 174, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                    .addComponent(Cbjurusan, javax.swing.GroupLayout.Alignment.LEADING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                        .addComponent(RbLakilaki)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(RbPerempuan)))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 39, Short.MAX_VALUE))))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 287, Short.MAX_VALUE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(70, 70, 70)
                        .addComponent(btnSimpan)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(btbBatal))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(32, 32, 32)
                        .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 244, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblNPM)
                    .addComponent(tfNPM, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lbljeniskelamin)
                    .addComponent(RbLakilaki)
                    .addComponent(RbPerempuan))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lbljurusan)
                    .addComponent(Cbjurusan, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnSimpan)
                    .addComponent(btbBatal))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel5)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(20, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>                       

private void tfNPMActionPerformed(java.awt.event.ActionEvent evt) {                                     

}                                    

private void btnSimpanActionPerformed(java.awt.event.ActionEvent evt) {                                         
// TODO add your handling code here:
    String JK, jurusan;
     if (RbLakilaki.isSelected())
     {
     JK = "Laki-laki";
     }
     else
     {
     JK="Perempuan";
   
     }
     jurusan = Cbjurusan.getSelectedItem().toString();
   
    output.setText("NPM : " + tfNPM.getText() + "\n" + "Jenis Kelamin :"+ JK + "\n" +"Jurusan :"+ jurusan +"\n" );

}                                        

private void btbBatalActionPerformed(java.awt.event.ActionEvent evt) {                                        
// TODO add your handling code here:
         int mesage=JOptionPane. showConfirmDialog(null, "Apakah Anda Yakin Keluar");
     if (mesage==JOptionPane.OK_OPTION)
     System.exit(1);

}                                       

private void RbLakilakiActionPerformed(java.awt.event.ActionEvent evt) {                                          
    // TODO add your handling code here:
}                                         

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

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new biodata().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify                    
    private javax.swing.JComboBox Cbjurusan;
    private javax.swing.JRadioButton RbLakilaki;
    private javax.swing.JRadioButton RbPerempuan;
    private javax.swing.JButton btbBatal;
    private javax.swing.JButton btnSimpan;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JLabel lblNPM;
    private javax.swing.JLabel lbljeniskelamin;
    private javax.swing.JLabel lbljurusan;
    private javax.swing.JTextArea output;
    private javax.swing.JTextField tfNPM;
    // End of variables declaration                  
}

Tidak ada komentar:

Posting Komentar