Advertisement
stevennathaniel

Source Code agar jRadioButton2 Langsung Dipilih

Jan 26th, 2015
323
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 6.64 KB | None | 0 0
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package latihan12;
  7.  
  8. import javax.swing.JRadioButton;
  9.  
  10. import javax.swing.SwingUtilities;
  11.  
  12. import javax.swing.ButtonGroup;
  13.  
  14.  
  15. /**
  16.  *
  17.  * @author steven
  18.  */
  19. public class FrameJComboBox12 extends javax.swing.JFrame {
  20.  
  21.     /**
  22.      * Creates new form FrameJComboBox12
  23.      */
  24.     public FrameJComboBox12() {
  25.         initComponents();
  26.        
  27.        
  28.         // kode agar jRadioButton2 langsung dipilih saat form di load atau dijalankan
  29.        
  30.         jRadioButton2.setSelected(true);
  31.        
  32.     }
  33.  
  34.     /**
  35.      * This method is called from within the constructor to initialize the form.
  36.      * WARNING: Do NOT modify this code. The content of this method is always
  37.      * regenerated by the Form Editor.
  38.      */
  39.     @SuppressWarnings("unchecked")
  40.     // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
  41.     private void initComponents() {
  42.  
  43.         buttonGroup1 = new javax.swing.ButtonGroup();
  44.         jRadioButton1 = new javax.swing.JRadioButton();
  45.         jRadioButton2 = new javax.swing.JRadioButton();
  46.         jRadioButton3 = new javax.swing.JRadioButton();
  47.         jButton1 = new javax.swing.JButton();
  48.  
  49.         setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
  50.  
  51.         jRadioButton1.setFont(new java.awt.Font("Cantarell", 1, 15)); // NOI18N
  52.         jRadioButton1.setText("Kucing");
  53.  
  54.         jRadioButton2.setFont(new java.awt.Font("Cantarell", 1, 15)); // NOI18N
  55.         jRadioButton2.setText("Tikus");
  56.  
  57.         jRadioButton3.setFont(new java.awt.Font("Cantarell", 1, 15)); // NOI18N
  58.         jRadioButton3.setText("Ikan");
  59.  
  60.         jButton1.setFont(new java.awt.Font("Cantarell", 1, 15)); // NOI18N
  61.         jButton1.setText("Print");
  62.         jButton1.addActionListener(new java.awt.event.ActionListener() {
  63.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  64.                 jButton1ActionPerformed(evt);
  65.             }
  66.         });
  67.  
  68.         javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
  69.         getContentPane().setLayout(layout);
  70.         layout.setHorizontalGroup(
  71.             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  72.             .addGroup(layout.createSequentialGroup()
  73.                 .addContainerGap()
  74.                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  75.                     .addGroup(layout.createSequentialGroup()
  76.                         .addComponent(jRadioButton3)
  77.                         .addGap(0, 0, Short.MAX_VALUE))
  78.                     .addGroup(layout.createSequentialGroup()
  79.                         .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  80.                             .addComponent(jRadioButton1)
  81.                             .addComponent(jRadioButton2))
  82.                         .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 77, Short.MAX_VALUE)
  83.                         .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 112, javax.swing.GroupLayout.PREFERRED_SIZE)))
  84.                 .addContainerGap())
  85.         );
  86.         layout.setVerticalGroup(
  87.             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  88.             .addGroup(layout.createSequentialGroup()
  89.                 .addContainerGap()
  90.                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
  91.                     .addGroup(layout.createSequentialGroup()
  92.                         .addComponent(jRadioButton1)
  93.                         .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  94.                         .addComponent(jRadioButton2))
  95.                     .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE))
  96.                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  97.                 .addComponent(jRadioButton3)
  98.                 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
  99.         );
  100.  
  101.         pack();
  102.     }// </editor-fold>                        
  103.  
  104.     private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                        
  105.         // TODO add your handling code here:
  106.        
  107.        
  108.        
  109.        
  110.        
  111.     }                                        
  112.  
  113.     /**
  114.      * @param args the command line arguments
  115.      */
  116.     public static void main(String args[]) {
  117.         /* Set the Nimbus look and feel */
  118.         //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
  119.         /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
  120.          * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
  121.          */
  122.         try {
  123.             for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
  124.                 if ("Nimbus".equals(info.getName())) {
  125.                     javax.swing.UIManager.setLookAndFeel(info.getClassName());
  126.                     break;
  127.                 }
  128.             }
  129.         } catch (ClassNotFoundException ex) {
  130.             java.util.logging.Logger.getLogger(FrameJComboBox12.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  131.         } catch (InstantiationException ex) {
  132.             java.util.logging.Logger.getLogger(FrameJComboBox12.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  133.         } catch (IllegalAccessException ex) {
  134.             java.util.logging.Logger.getLogger(FrameJComboBox12.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  135.         } catch (javax.swing.UnsupportedLookAndFeelException ex) {
  136.             java.util.logging.Logger.getLogger(FrameJComboBox12.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  137.         }
  138.         //</editor-fold>
  139.  
  140.         /* Create and display the form */
  141.         java.awt.EventQueue.invokeLater(new Runnable() {
  142.             public void run() {
  143.                 new FrameJComboBox12().setVisible(true);
  144.             }
  145.         });
  146.     }
  147.  
  148.     // Variables declaration - do not modify                    
  149.     private javax.swing.ButtonGroup buttonGroup1;
  150.     private javax.swing.JButton jButton1;
  151.     private javax.swing.JRadioButton jRadioButton1;
  152.     private javax.swing.JRadioButton jRadioButton2;
  153.     private javax.swing.JRadioButton jRadioButton3;
  154.     // End of variables declaration                  
  155. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement