tengo el siguiente codigo
Código:
el problema lo tengo cuandoi hago this.textArea.setText(result); me arroja un invalid thread access, intente creando otro thread pero igual me arroja la exepcion, y la verdad ya no se me ocurren ideas :(public class TxRxSerial implements SerialPortEventListener{ private Shell sShell = null; // @jve:decl-index=0:visual-constraint="210,24" private Composite composite = null; private Composite composite1 = null; private Label lblMensage = null; private Text txtMensage = null; private Button btnCerrar = null; private Composite composite2 = null; private Trasmisor tx; // @jve:decl-index=0: private Thread lector=null; private Text textArea = null; private String result=""; /** * This method initializes sShell * */ private void createSShell() { try { tx = new Trasmisor(); tx.getTPort().addEventListener(this); sShell = new Shell(); sShell.setLayout(new GridLayout()); createComposite(); createComposite2(); createComposite1(); sShell.setSize(new Point(315, 269)); } catch (TooManyListenersException e) { e.printStackTrace(); } } public void run(){ createSShell(); sShell.open(); } /** * This method initializes composite * */ private void createComposite() { GridData gridData5 = new GridData(); gridData5.horizontalAlignment = GridData.FILL; gridData5.grabExcessHorizontalSpace = false; gridData5.grabExcessVerticalSpace = false; gridData5.verticalAlignment = GridData.BEGINNING; GridData gridData3 = new GridData(); gridData3.horizontalAlignment = GridData.FILL; gridData3.grabExcessHorizontalSpace = true; gridData3.grabExcessVerticalSpace = true; gridData3.verticalAlignment = GridData.FILL; GridLayout gridLayout = new GridLayout(); gridLayout.numColumns = 2; GridData gridData = new GridData(); gridData.grabExcessHorizontalSpace = true; gridData.horizontalAlignment = GridData.FILL; gridData.verticalAlignment = GridData.FILL; gridData.grabExcessVerticalSpace = true; composite = new Composite(sShell, SWT.NONE); composite.setLayoutData(gridData); composite.setLayout(gridLayout); lblMensage = new Label(composite, SWT.NONE); lblMensage.setText("Texto"); lblMensage.setLayoutData(gridData5); txtMensage = new Text(composite, SWT.MULTI); txtMensage.setLayoutData(gridData3); txtMensage.addModifyListener(new ModifyListener(){ public void modifyText(ModifyEvent e) { tx.transmitir(txtMensage.getText()); } }); } /** * This method initializes composite1 * */ private void createComposite1() { GridData gridData2 = new GridData(); gridData2.horizontalAlignment = GridData.END; gridData2.grabExcessHorizontalSpace = true; gridData2.verticalAlignment = GridData.FILL; GridLayout gridLayout1 = new GridLayout(); gridLayout1.numColumns = 1; GridData gridData1 = new GridData(); gridData1.grabExcessHorizontalSpace = false; gridData1.horizontalAlignment = GridData.FILL; gridData1.verticalAlignment = GridData.CENTER; gridData1.grabExcessVerticalSpace = false; composite1 = new Composite(sShell, SWT.NONE); composite1.setLayoutData(gridData1); composite1.setLayout(gridLayout1); btnCerrar = new Button(composite1, SWT.NONE); btnCerrar.setText("&Cerrar"); btnCerrar.setLayoutData(gridData2); } /** * This method initializes composite2 * */ private void createComposite2() { GridData gridData9 = new GridData(); gridData9.horizontalAlignment = GridData.FILL; gridData9.grabExcessHorizontalSpace = true; gridData9.grabExcessVerticalSpace = true; gridData9.verticalAlignment = GridData.FILL; GridData gridData8 = new GridData(); gridData8.horizontalAlignment = GridData.FILL; gridData8.grabExcessHorizontalSpace = true; gridData8.grabExcessVerticalSpace = true; gridData8.verticalAlignment = GridData.FILL; composite2 = new Composite(sShell, SWT.NONE); composite2.setLayout(new GridLayout()); composite2.setLayoutData(gridData8); textArea = new Text(composite2, SWT.MULTI | SWT.WRAP | SWT.V_SCROLL); textArea.setEnabled(false); textArea.setLayoutData(gridData9); } public void serialEvent(SerialPortEvent event) { int evento = event.getEventType(); if(evento == SerialPortEvent.DATA_AVAILABLE){ String texto = tx.recivir(); System.out.println("reciviendo mensage: "+texto); this.textArea.setText(result); } } }
alguna sugerencia??
agradesco cualkier ayuda