Foros del Web » Programación para mayores de 30 ;) » Java »

Netbeans 8 y encontrar fallos.

Estas en el tema de Netbeans 8 y encontrar fallos. en el foro de Java en Foros del Web. Hola: Tengo un código medio hecho en el cual no se el motivo de los fallos. Se trata de encender y apagar un Led con ...
  #1 (permalink)  
Antiguo 05/03/2015, 23:21
 
Fecha de Ingreso: mayo-2007
Ubicación: PIC-16F84A
Mensajes: 727
Antigüedad: 16 años, 11 meses
Puntos: 8
Netbeans 8 y encontrar fallos.

Hola:

Tengo un código medio hecho en el cual no se el motivo de los fallos. Se trata de encender y apagar un Led con Netbeans 8 en mi caso y Arduino.

Código Java:
Ver original
  1. import gnu.io.CommPortIdentifier;
  2. import gnu.io.SerialPort;
  3. import java.io.OutputStream;
  4. import java.util.Enumeration;
  5. import javax.swing.JOptionPane;
  6.  
  7. /*
  8.  * To change this license header, choose License Headers in Project Properties.
  9.  * To change this template file, choose Tools | Templates
  10.  * and open the template in the editor.
  11.  */
  12.  
  13. /**
  14.  *
  15.  * @author Meta
  16.  */
  17. public class JAVADUINO_JFrame extends javax.swing.JFrame {
  18.  
  19.     /**
  20.      * Creates new form JAVADUINO_JFrame
  21.      */
  22.    
  23.     private static final String L8ON = "Led_8_ON";
  24.     private static final String L8OFF = "Led_8_OFF";
  25.    
  26.     // Variables de conexión.
  27.     private final OutputStream output = null;
  28.     SerialPort serialPort;
  29.     private final String PUERTO = "COM4";
  30.    
  31.     private static final int TIMEOUT = 2000;
  32.    
  33.     private static final int DATA_RATE = 115200;
  34.    
  35.     public JAVADUINO_JFrame() {
  36.         initComponents();
  37.         inicializarConexion();
  38.     }
  39.  
  40.     public final void inicializarConexion(){
  41.         CommPortIdentifier puertoID = null;
  42.         Enumeration puertoEnum = CommPortIdentifier.getPortIdentifiers();
  43.        
  44.         while(puertoEnum.hasMoreElements()){
  45.             CommPortIdentifier actualPuertoID = (CommPortIdentifier) puertoEnum.nextElement();
  46.             if (PUERTO.equals(actualPuertoID.getName())){
  47.                 puertoID = actualPuertoID;
  48.                 break;
  49.             }
  50.         }
  51.     }
  52.    
  53.     if (puertoID == null){
  54.     mostrarError("No se puede conectar al puerto.");
  55.     System.exit(ERROR);
  56. }
  57.    
  58.     try{
  59.         serialPort = (SerialPort) puertoID.open(this.getClass().getName(), TIMEOUT);
  60.         // Parámetros puerto serie.
  61.         serialPort.setSerialPortParams(DATA_RATE, SerialPort.DATABITS_8, SerialPort.STOPBITS_2, SerialPort.PARITY_NONE);
  62.         output = serialPort.getOutputStream();
  63. }
  64.     catch (Exception e){
  65.     mostrarError(e.getMessage());
  66.     System.exit(ERROR);
  67. }
  68.  
  69.     private void enviarDatos(String datos){
  70.         try{
  71.             output.write(datos.getBytes());
  72.         }
  73.         catch(Exception e){
  74.             mostrarError("ERROR");
  75.             System.exit(ERROR);
  76.         }
  77.     }
  78.    
  79.     public void mostrarError(String mensaje){
  80.         JOptionPane.showMessageDialog(this, mensaje, "ERROR", JOptionPane.ERROR_MESSAGE);
  81.        
  82.     }
  83.     /**
  84.      * This method is called from within the constructor to initialize the form.
  85.      * WARNING: Do NOT modify this code. The content of this method is always
  86.      * regenerated by the Form Editor.
  87.      */
  88.     @SuppressWarnings("unchecked")
  89.     // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
  90.     private void initComponents() {
  91.  
  92.         jButton1 = new javax.swing.JButton();
  93.         jButton2 = new javax.swing.JButton();
  94.  
  95.         setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
  96.  
  97.         jButton1.setText("ON");
  98.  
  99.         jButton2.setText("OFF");
  100.  
  101.         javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
  102.         getContentPane().setLayout(layout);
  103.         layout.setHorizontalGroup(
  104.             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  105.             .addGroup(layout.createSequentialGroup()
  106.                 .addGap(21, 21, 21)
  107.                 .addComponent(jButton1)
  108.                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 101, Short.MAX_VALUE)
  109.                 .addComponent(jButton2)
  110.                 .addGap(45, 45, 45))
  111.         );
  112.         layout.setVerticalGroup(
  113.             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  114.             .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
  115.                 .addContainerGap(250, Short.MAX_VALUE)
  116.                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  117.                     .addComponent(jButton1)
  118.                     .addComponent(jButton2))
  119.                 .addGap(27, 27, 27))
  120.         );
  121.  
  122.         pack();
  123.     }// </editor-fold>                        
  124.  
  125.     /**
  126.      * @param args the command line arguments
  127.      */
  128.     public static void main(String args[]) {
  129.         /* Set the Nimbus look and feel */
  130.         //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
  131.         /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
  132.          * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
  133.          */
  134.         try {
  135.             for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
  136.                 if ("Nimbus".equals(info.getName())) {
  137.                     javax.swing.UIManager.setLookAndFeel(info.getClassName());
  138.                     break;
  139.                 }
  140.             }
  141.         } catch (ClassNotFoundException ex) {
  142.             java.util.logging.Logger.getLogger(JAVADUINO_JFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  143.         } catch (InstantiationException ex) {
  144.             java.util.logging.Logger.getLogger(JAVADUINO_JFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  145.         } catch (IllegalAccessException ex) {
  146.             java.util.logging.Logger.getLogger(JAVADUINO_JFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  147.         } catch (javax.swing.UnsupportedLookAndFeelException ex) {
  148.             java.util.logging.Logger.getLogger(JAVADUINO_JFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  149.         }
  150.         //</editor-fold>
  151.  
  152.         /* Create and display the form */
  153.         java.awt.EventQueue.invokeLater(new Runnable() {
  154.             public void run() {
  155.                 new JAVADUINO_JFrame().setVisible(true);
  156.             }
  157.         });
  158.     }
  159.  
  160.     // Variables declaration - do not modify                    
  161.     private javax.swing.JButton jButton1;
  162.     private javax.swing.JButton jButton2;
  163.     // End of variables declaration                  
  164.  
  165.     private void mostrarError(String no_se_puede_conectar_al_puerto) {
  166.         throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
  167.     }
  168. }

Todavía no he programado los botones, hay que acabar con los fallos primero. Los mensajes que me dan son estos.
Cita:
run:
java.lang.ClassFormatError: Duplicate field name&signature in class file JAVADUINO_JFrame
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java :760)
at java.security.SecureClassLoader.defineClass(Secure ClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader .java:455)
at java.net.URLClassLoader.access$100(URLClassLoader. java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java: 367)
at java.net.URLClassLoader$1.run(URLClassLoader.java: 361)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.j ava:360)
at java.lang.ClassLoader.loadClass(ClassLoader.java:4 24)
at sun.misc.Launcher$AppClassLoader.loadClass(Launche r.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:3 57)
at sun.launcher.LauncherHelper.checkAndLoadMain(Launc herHelper.java:495)
Exception in thread "main" Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)
He segudio los tutoriales hasta el minuto 37':30" de este vídeo.
https://www.youtube.com/watch?v=4Hr_LZ62SdY

¿Alguna idea?

Saludos.
__________________
Meta Shell, VERSIÓN 1.2.2
Descargar
  #2 (permalink)  
Antiguo 06/03/2015, 02:47
Avatar de Xerelo  
Fecha de Ingreso: mayo-2009
Mensajes: 2.175
Antigüedad: 14 años, 11 meses
Puntos: 306
Respuesta: Netbeans 8 y encontrar fallos.

No te puedo asegurar que sea la causa del error, pero este trozo de código no está dentro de ningún método.

Cita:
if (puertoID == null){
mostrarError("No se puede conectar al puerto.");
System.exit(ERROR);
}

try{
serialPort = (SerialPort) puertoID.open(this.getClass().getName(), TIMEOUT);
// Parámetros puerto serie.
serialPort.setSerialPortParams(DATA_RATE, SerialPort.DATABITS_8, SerialPort.STOPBITS_2, SerialPort.PARITY_NONE);
output = serialPort.getOutputStream();
}
catch (Exception e){
mostrarError(e.getMessage());
System.exit(ERROR);
}
__________________
Cada vez que solucionas los problemas de alguien que no se esfuerza, piensa en que el día de mañana puede llegar a ser tu compañero de trabajo, o peor, tu jefe.
  #3 (permalink)  
Antiguo 06/03/2015, 07:17
 
Fecha de Ingreso: mayo-2007
Ubicación: PIC-16F84A
Mensajes: 727
Antigüedad: 16 años, 11 meses
Puntos: 8
Respuesta: Netbeans 8 y encontrar fallos.

Hola:

Código algo corregido.
Código Java:
Ver original
  1. import java.io.OutputStream;
  2. import gnu.io.CommPortIdentifier;
  3. import gnu.io.SerialPort;
  4. import java.util.Enumeration;
  5. import javax.swing.JOptionPane;
  6.  
  7. /*
  8.  * To change this license header, choose License Headers in Project Properties.
  9.  * To change this template file, choose Tools | Templates
  10.  * and open the template in the editor.
  11.  */
  12.  
  13. /**
  14.  *
  15.  * @author Meta
  16.  */
  17. public class JAVADUINO_JFrame extends javax.swing.JFrame {
  18.  
  19.     /**
  20.      * Creates new form JAVADUINO_JFrame
  21.      */
  22.    
  23.     private static final String L8ON = "Led_8_ON";
  24.     private static final String L8OFF = "Led_8_OFF";
  25.    
  26.     // Variables de conexión.
  27.     private final OutputStream output = null;
  28.     SerialPort serialPort;
  29.     private final String PUERTO = "COM4";
  30.    
  31.     private static final int TIMEOUT = 2000;
  32.    
  33.     private static final int DATA_RATE = 115200;
  34.    
  35.     public JAVADUINO_JFrame() {
  36.         initComponents();
  37.         inicializarConexion();
  38.     }
  39.  
  40.     public final void inicializarConexion(){
  41.         CommPortIdentifier puertoID = null;
  42.         Enumeration puertoEnum = CommPortIdentifier.getPortIdentifiers();
  43.        
  44.         while(puertoEnum.hasMoreElements()){
  45.             CommPortIdentifier actualPuertoID = (CommPortIdentifier) puertoEnum.nextElement();
  46.             if (PUERTO.equals(actualPuertoID.getName())){
  47.                 puertoID = actualPuertoID;
  48.                 break;
  49.             }
  50.         }
  51.        
  52.             if (puertoID == null){
  53.     mostrarError("No se puede conectar al puerto.");
  54.     System.exit(ERROR);
  55. }
  56.    
  57.     try{
  58.         serialPort = (SerialPort) puertoID.open(this.getClass().getName(), TIMEOUT);
  59.         // Parámetros puerto serie.
  60.         serialPort.setSerialPortParams(DATA_RATE, SerialPort.DATABITS_8, SerialPort.STOPBITS_2, SerialPort.PARITY_NONE);
  61.         output = serialPort.getOutputStream();
  62. }
  63.     catch (Exception e){
  64.     mostrarError(e.getMessage());
  65.     System.exit(ERROR);
  66. }
  67.     }
  68.    
  69.  
  70.     private void enviarDatos(String datos){
  71.         try{
  72.             output.write(datos.getBytes());
  73.         }
  74.         catch(Exception e){
  75.             mostrarError("ERROR");
  76.             System.exit(ERROR);
  77.         }
  78.     }
  79.    
  80.     public void mostrarError(String mensaje){
  81.         JOptionPane.showMessageDialog(this, mensaje, "ERROR", JOptionPane.ERROR_MESSAGE);
  82.        
  83.     }
  84.     /**
  85.      * This method is called from within the constructor to initialize the form.
  86.      * WARNING: Do NOT modify this code. The content of this method is always
  87.      * regenerated by the Form Editor.
  88.      */
  89.     @SuppressWarnings("unchecked")
  90.     // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
  91.     private void initComponents() {
  92.  
  93.         jButton1 = new javax.swing.JButton();
  94.         jButton2 = new javax.swing.JButton();
  95.  
  96.         setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
  97.  
  98.         jButton1.setText("ON");
  99.  
  100.         jButton2.setText("OFF");
  101.  
  102.         javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
  103.         getContentPane().setLayout(layout);
  104.         layout.setHorizontalGroup(
  105.             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  106.             .addGroup(layout.createSequentialGroup()
  107.                 .addGap(21, 21, 21)
  108.                 .addComponent(jButton1)
  109.                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 101, Short.MAX_VALUE)
  110.                 .addComponent(jButton2)
  111.                 .addGap(45, 45, 45))
  112.         );
  113.         layout.setVerticalGroup(
  114.             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  115.             .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
  116.                 .addContainerGap(250, Short.MAX_VALUE)
  117.                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  118.                     .addComponent(jButton1)
  119.                     .addComponent(jButton2))
  120.                 .addGap(27, 27, 27))
  121.         );
  122.  
  123.         pack();
  124.     }// </editor-fold>                        
  125.  
  126.     /**
  127.      * @param args the command line arguments
  128.      */
  129.     public static void main(String args[]) {
  130.         /* Set the Nimbus look and feel */
  131.         //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
  132.         /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
  133.          * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
  134.          */
  135.         try {
  136.             for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
  137.                 if ("Nimbus".equals(info.getName())) {
  138.                     javax.swing.UIManager.setLookAndFeel(info.getClassName());
  139.                     break;
  140.                 }
  141.             }
  142.         } catch (ClassNotFoundException ex) {
  143.             java.util.logging.Logger.getLogger(JAVADUINO_JFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  144.         } catch (InstantiationException ex) {
  145.             java.util.logging.Logger.getLogger(JAVADUINO_JFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  146.         } catch (IllegalAccessException ex) {
  147.             java.util.logging.Logger.getLogger(JAVADUINO_JFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  148.         } catch (javax.swing.UnsupportedLookAndFeelException ex) {
  149.             java.util.logging.Logger.getLogger(JAVADUINO_JFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  150.         }
  151.         //</editor-fold>
  152.  
  153.         /* Create and display the form */
  154.         java.awt.EventQueue.invokeLater(new Runnable() {
  155.             public void run() {
  156.                 new JAVADUINO_JFrame().setVisible(true);
  157.             }
  158.         });
  159.     }
  160.  
  161.     // Variables declaration - do not modify                    
  162.     private javax.swing.JButton jButton1;
  163.     private javax.swing.JButton jButton2;
  164.     // End of variables declaration                  
  165.  
  166.     private void mostrarError(String no_se_puede_conectar_al_puerto) {
  167.         throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
  168.     }
  169. }

Me sale este error.
Cita:
run:
java.lang.ExceptionInInitializerError
Caused by: java.lang.RuntimeException: Uncompilable source code - method mostrarError(java.lang.String) is already defined in class JAVADUINO_JFrame
at JAVADUINO_JFrame.<clinit>(JAVADUINO_JFrame.java:17 4)
Exception in thread "main" Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)
__________________
Meta Shell, VERSIÓN 1.2.2
Descargar
  #4 (permalink)  
Antiguo 06/03/2015, 07:49
Avatar de Xerelo  
Fecha de Ingreso: mayo-2009
Mensajes: 2.175
Antigüedad: 14 años, 11 meses
Puntos: 306
Respuesta: Netbeans 8 y encontrar fallos.

Si tienes que programar, aunque sea poco lo que tengas que hacer, deberías primero leer un tutorial básico.

Cita:
private void mostrarError(String no_se_puede_conectar_al_puerto) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
No puede haber dos métodos que se llamen igual y que reciban los mismos parámetros, tienes dos métodos mostrarError que reciben una string.
__________________
Cada vez que solucionas los problemas de alguien que no se esfuerza, piensa en que el día de mañana puede llegar a ser tu compañero de trabajo, o peor, tu jefe.
  #5 (permalink)  
Antiguo 06/03/2015, 12:50
 
Fecha de Ingreso: mayo-2007
Ubicación: PIC-16F84A
Mensajes: 727
Antigüedad: 16 años, 11 meses
Puntos: 8
Respuesta: Netbeans 8 y encontrar fallos.

He empezado de nuevo.

El código ya me enciende los Led y los apaga. Este es su código por si alguien le pueda interesar y este si funciona.

Código Java:
Ver original
  1. import gnu.io.CommPortIdentifier;
  2. import gnu.io.SerialPort;
  3. import java.io.OutputStream;
  4. import java.util.Enumeration;
  5. import javax.swing.JOptionPane;
  6.  
  7. /*
  8.  * To change this license header, choose License Headers in Project Properties.
  9.  * To change this template file, choose Tools | Templates
  10.  * and open the template in the editor.
  11.  */
  12.  
  13. /**
  14.  *
  15.  * @author Meta
  16.  */
  17. public class JAVADUINO_Frame extends javax.swing.JFrame {
  18.  
  19.     /**
  20.      * Creates new form JAVADUINO_Frame
  21.      */
  22.    
  23.     private static final String L8on = "Led_8_ON";
  24.     private static final String L8off = "Led_8_OFF";
  25.    
  26.     // Variables de conexión.
  27.     private OutputStream output = null;
  28.     SerialPort serialPort;
  29.     private final String PUERTO = "COM4";
  30.    
  31.     private static final int TIMEOUT = 2000; // 2 segundos.
  32.    
  33.     private static final int DATA_RATE = 115200; // Baudios.
  34.    
  35.     public JAVADUINO_Frame() {
  36.         initComponents();
  37.         inicializarConexion();
  38.     }
  39.    
  40.     public void inicializarConexion(){
  41.         CommPortIdentifier puertoID = null;
  42.         Enumeration puertoEnum = CommPortIdentifier.getPortIdentifiers();
  43.        
  44.         while (puertoEnum.hasMoreElements()){
  45.             CommPortIdentifier actualPuertoID = (CommPortIdentifier) puertoEnum.nextElement();
  46.             if (PUERTO.equals(actualPuertoID.getName())){
  47.                 puertoID = actualPuertoID;
  48.                 break;
  49.             }
  50.         }
  51.        
  52.         if (puertoID == null){
  53.             mostrarError("No se puede conectar al puerto");
  54.             System.exit(ERROR);
  55.         }
  56.        
  57.         try{
  58.             serialPort = (SerialPort) puertoID.open(this.getClass().getName(), TIMEOUT);
  59.             // Parámatros puerto serie.
  60.            
  61.             serialPort.setSerialPortParams(DATA_RATE, SerialPort.DATABITS_8, SerialPort.STOPBITS_2, SerialPort.PARITY_NONE);
  62.            
  63.             output = serialPort.getOutputStream();
  64.         } catch (Exception e){
  65.             mostrarError(e.getMessage());
  66.             System.exit(ERROR);
  67.         }
  68.     }
  69.    
  70.     private void enviarDatos(String datos){
  71.         try{
  72.             output.write(datos.getBytes());
  73.         } catch (Exception e){
  74.             mostrarError("ERROR");
  75.             System.exit(ERROR);
  76.         }
  77.     }
  78.    
  79.     public void mostrarError(String mensaje){
  80.         JOptionPane.showMessageDialog(this, mensaje, "ERROR", JOptionPane.ERROR_MESSAGE);    
  81.     }
  82.     /**
  83.      * This method is called from within the constructor to initialize the form.
  84.      * WARNING: Do NOT modify this code. The content of this method is always
  85.      * regenerated by the Form Editor.
  86.      */
  87.     @SuppressWarnings("unchecked")
  88.     // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
  89.     private void initComponents() {
  90.  
  91.         jButton1 = new javax.swing.JButton();
  92.         jButton2 = new javax.swing.JButton();
  93.  
  94.         setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
  95.         setTitle("JAVADUINO by Meta");
  96.  
  97.         jButton1.setText("ON");
  98.         jButton1.addActionListener(new java.awt.event.ActionListener() {
  99.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  100.                 jButton1ActionPerformed(evt);
  101.             }
  102.         });
  103.  
  104.         jButton2.setText("OFF");
  105.         jButton2.addActionListener(new java.awt.event.ActionListener() {
  106.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  107.                 jButton2ActionPerformed(evt);
  108.             }
  109.         });
  110.  
  111.         javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
  112.         getContentPane().setLayout(layout);
  113.         layout.setHorizontalGroup(
  114.             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  115.             .addGroup(layout.createSequentialGroup()
  116.                 .addContainerGap()
  117.                 .addComponent(jButton1)
  118.                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 99, Short.MAX_VALUE)
  119.                 .addComponent(jButton2)
  120.                 .addContainerGap())
  121.         );
  122.         layout.setVerticalGroup(
  123.             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  124.             .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
  125.                 .addContainerGap(92, Short.MAX_VALUE)
  126.                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  127.                     .addComponent(jButton1)
  128.                     .addComponent(jButton2))
  129.                 .addGap(26, 26, 26))
  130.         );
  131.  
  132.         pack();
  133.     }// </editor-fold>                        
  134.  
  135.     private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                        
  136.         // TODO add your handling code here:
  137.         enviarDatos(L8on);
  138.     }                                        
  139.  
  140.     private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {                                        
  141.         // TODO add your handling code here:
  142.         enviarDatos(L8off);
  143.     }                                        
  144.  
  145.     /**
  146.      * @param args the command line arguments
  147.      */
  148.     public static void main(String args[]) {
  149.         /* Set the Nimbus look and feel */
  150.         //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
  151.         /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
  152.          * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
  153.          */
  154.         try {
  155.             for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
  156.                 if ("Nimbus".equals(info.getName())) {
  157.                     javax.swing.UIManager.setLookAndFeel(info.getClassName());
  158.                     break;
  159.                 }
  160.             }
  161.         } catch (ClassNotFoundException ex) {
  162.             java.util.logging.Logger.getLogger(JAVADUINO_Frame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  163.         } catch (InstantiationException ex) {
  164.             java.util.logging.Logger.getLogger(JAVADUINO_Frame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  165.         } catch (IllegalAccessException ex) {
  166.             java.util.logging.Logger.getLogger(JAVADUINO_Frame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  167.         } catch (javax.swing.UnsupportedLookAndFeelException ex) {
  168.             java.util.logging.Logger.getLogger(JAVADUINO_Frame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  169.         }
  170.         //</editor-fold>
  171.  
  172.         /* Create and display the form */
  173.         java.awt.EventQueue.invokeLater(new Runnable() {
  174.             public void run() {
  175.                 new JAVADUINO_Frame().setVisible(true);
  176.             }
  177.         });
  178.     }
  179.  
  180.     // Variables declaration - do not modify                    
  181.     private javax.swing.JButton jButton1;
  182.     private javax.swing.JButton jButton2;
  183.     // End of variables declaration                  
  184. }

https://www.youtube.com/watch?v=JAwCa4Uk6tA

He instalado todo otra vez JAVA 32 bits en Windows 7 de 64 bits.

Ahora me toca saber como se lee los datos y los muestra en un richTextBox.


Saludos y gracias por todo.
__________________
Meta Shell, VERSIÓN 1.2.2
Descargar

Etiquetas: netbeans
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 05:05.