Hi,
I'm new, and I want develop a Applet to communicate with RS-232, I use RxTX libraries. I try to convert an application sample (that works fine) into a applet, but it doesn't work.
Here is the code:

import java.awt.event.MouseListener;
import java.awt.event.MouseEvent;
import java.applet.Applet;
import java.awt.Graphics;

import gnu.io.CommPort;
import gnu.io.CommPortIdentifier;
import gnu.io.SerialPort;
import gnu.io.SerialPortEvent;
import gnu.io.SerialPortEventListener;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;




public class TwoWaySerialComm extends Applet
{

StringBuffer buffer;

CommPort commPort;
CommPortIdentifier portId;
SerialPort serialPort;
InputStream inputStream;

public void init()
{

buffer = new StringBuffer();
addItem("initializing... ");


// initalize serial port

try
{
showStatus("1");
CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier("COM2");

/*
if ( portId.isCurrentlyOwned() )
{
showStatus("1.5");
System.out.println("Error: Port is currently in use");
}
else
{
showStatus("2");
CommPort commPort = portId.open(this.getClass().getName(),2000);
if ( commPort instanceof SerialPort )
{
SerialPort serialPort = (SerialPort) commPort;
serialPort.setSerialPortParams(9600,SerialPort.DAT ABITS_8,SerialPort.STOPBITS_1,SerialPort.PARITY_NO NE);
showStatus("3");
InputStream inputStream = serialPort.getInputStream();

serialPort.notifyOnDataAvailable(true);

showStatus("4");

//serialPort.addEventListener(this);
serialPort.addEventListener(new SerialReader(inputStream));

showStatus("5");



}
}
*/
}
catch (Exception e)
{
e.printStackTrace();
}



}


public void start() {
addItem("starting... ");
}

public void stop() {
addItem("stopping... ");
}

public void destroy() {
addItem("preparing for unloading...");
}

void addItem(String newWord) {
System.out.println(newWord);
buffer.append(newWord);
repaint();
}

public void paint(Graphics g) {
//Draw a Rectangle around the applet's display area.
g.drawRect(0, 0, getWidth() - 1,getHeight() - 1);

//Draw the current string inside the rectangle.
g.drawString(buffer.toString(), 5, 15);
}






public class SerialReader implements SerialPortEventListener
{
private InputStream in;
private byte[] buffer = new byte[1024];

public SerialReader ( InputStream in )
{
this.in = in;
}


public void serialEvent(SerialPortEvent event)
{
showStatus("Evento Port Serial");

switch (event.getEventType())
{
case SerialPortEvent.BI:
case SerialPortEvent.OE:
case SerialPortEvent.FE:
case SerialPortEvent.PE:
case SerialPortEvent.CD:
case SerialPortEvent.CTS:
case SerialPortEvent.DSR:
case SerialPortEvent.RI:
case SerialPortEvent.OUTPUT_BUFFER_EMPTY:
break;
case SerialPortEvent.DATA_AVAILABLE:

int data;

try
{
int len = 0;
byte[] buffer = new byte[1024];

while ( ( data = inputStream.read()) > -1 )
{
if ( data == '\n' )
{
break;
}
buffer[len++] = (byte) data;
}
showStatus("Leido Código");
}
catch ( IOException e )
{
showStatus("Error");
e.printStackTrace();
System.exit(-1);
}
}
}
}
}

Someone has any idea?

Than you