Ver Mensaje Individual
  #4 (permalink)  
Antiguo 14/04/2012, 13:03
Bladsmickey
 
Fecha de Ingreso: enero-2011
Mensajes: 33
Antigüedad: 14 años
Puntos: 0
Respuesta: Constructores!

Código Java:
Ver original
  1. /*
  2.  * To change this template, choose Tools | Templates
  3.  * and open the template in the editor.
  4.  */
  5.  
  6. /**
  7.  *
  8.  * @author Bladsmickey
  9.  */
  10. public class prueba extends javax.swing.JFrame {
  11.  
  12.     /**
  13.      * Creates new form prueba
  14.      */
  15.     public prueba() {
  16.         initComponents();
  17.     }
  18.  
  19.     /**
  20.      * This method is called from within the constructor to initialize the form.
  21.      * WARNING: Do NOT modify this code. The content of this method is always
  22.      * regenerated by the Form Editor.
  23.      */
  24.     @SuppressWarnings("unchecked")
  25.     // <editor-fold defaultstate="collapsed" desc="Generated Code">
  26.     private void initComponents() {
  27.  
  28.         jLabel1 = new javax.swing.JLabel();
  29.         jLabel2 = new javax.swing.JLabel();
  30.         jLabel3 = new javax.swing.JLabel();
  31.         jButton1 = new javax.swing.JButton();
  32.  
  33.         setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
  34.  
  35.         jLabel1.setText("Campo Nombre");
  36.  
  37.         jLabel2.setText("Campo Apellido");
  38.  
  39.         jLabel3.setText("Campo Cedula");
  40.  
  41.         jButton1.setText("Probar Variables");
  42.         jButton1.addActionListener(new java.awt.event.ActionListener() {
  43.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  44.                 jButton1ActionPerformed(evt);
  45.             }
  46.         });
  47.  
  48.         javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
  49.         getContentPane().setLayout(layout);
  50.         layout.setHorizontalGroup(
  51.             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  52.             .addGroup(layout.createSequentialGroup()
  53.                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  54.                     .addGroup(layout.createSequentialGroup()
  55.                         .addContainerGap()
  56.                         .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  57.                             .addComponent(jLabel1)
  58.                             .addComponent(jLabel2)
  59.                             .addComponent(jLabel3)))
  60.                     .addGroup(layout.createSequentialGroup()
  61.                         .addGap(155, 155, 155)
  62.                         .addComponent(jButton1)))
  63.                 .addContainerGap(134, Short.MAX_VALUE))
  64.         );
  65.         layout.setVerticalGroup(
  66.             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  67.             .addGroup(layout.createSequentialGroup()
  68.                 .addContainerGap()
  69.                 .addComponent(jLabel1)
  70.                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  71.                 .addComponent(jLabel2)
  72.                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  73.                 .addComponent(jLabel3)
  74.                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 167, Short.MAX_VALUE)
  75.                 .addComponent(jButton1)
  76.                 .addGap(40, 40, 40))
  77.         );
  78.  
  79.         pack();
  80.     }// </editor-fold>
  81.  
  82.     private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
  83. variables b=new variables();        // TODO add your handling code here:
  84. jLabel1.setText(b.nom());
  85. jLabel2.setText(b.ape());
  86. jLabel2.setText(b.cedu());
  87.     }
  88.  
  89.     /**
  90.      * @param args the command line arguments
  91.      */
  92.     public static void main(String args[]) {
  93.         /*
  94.          * Set the Nimbus look and feel
  95.          */
  96.         //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
  97.         /*
  98.          * If Nimbus (introduced in Java SE 6) is not available, stay with the
  99.          * default look and feel. For details see
  100.          * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
  101.          */
  102.         try {
  103.             for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
  104.                 if ("Nimbus".equals(info.getName())) {
  105.                     javax.swing.UIManager.setLookAndFeel(info.getClassName());
  106.                     break;
  107.                 }
  108.             }
  109.         } catch (ClassNotFoundException ex) {
  110.             java.util.logging.Logger.getLogger(prueba.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  111.         } catch (InstantiationException ex) {
  112.             java.util.logging.Logger.getLogger(prueba.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  113.         } catch (IllegalAccessException ex) {
  114.             java.util.logging.Logger.getLogger(prueba.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  115.         } catch (javax.swing.UnsupportedLookAndFeelException ex) {
  116.             java.util.logging.Logger.getLogger(prueba.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  117.         }
  118.         //</editor-fold>
  119.  
  120.         /*
  121.          * Create and display the form
  122.          */
  123.         java.awt.EventQueue.invokeLater(new Runnable() {
  124.  
  125.             public void run() {
  126.                 new prueba().setVisible(true);
  127.             }
  128.         });
  129.     }
  130.     // Variables declaration - do not modify
  131.     private javax.swing.JButton jButton1;
  132.     private javax.swing.JLabel jLabel1;
  133.     private javax.swing.JLabel jLabel2;
  134.     private javax.swing.JLabel jLabel3;
  135.     // End of variables declaration
  136. }