}
}
public void itemStateChanged(ItemEvent ev)
{
SerialPort port;
String sel = (String) ev.getItem();
int value = 0;
if (sel.equals("5"))
{
value = SerialPort.DATABITS_5;
}
else if (sel.equals("6"))
{
value = SerialPort.DATABITS_6;
}
else if (sel.equals("7"))
{
value = SerialPort.DATABITS_7;
}
else if (sel.equals("8"))
{
value = SerialPort.DATABITS_8;
}
else
{
this.showValue();
}
port = this.owner.port;
if ((value > 0) && (port != null))
{
/*
* Set the number of data bits.
*
* Note: we must set all of the parameters, not just
* the number of data bits, hence the use of get*
*/
try
{
port.setSerialPortParams(port.getBaudRate(),
value,
port.getStopBits(),
port.getParity());
}
catch (UnsupportedCommOperationException e)
{
System.out.println("Cannot set data bit size to "
+ sel + " for port "
+ port.getName());
}
}
this.owner.showValues();
}