marciokrollPJ 10 de set. de 2004
Eu estou com o mesmo problema, utilizando o SerialDemo, com Sistema Operacional windows 98, se vc souber de alguma coisa, me avise.
wetrainPJ 15 de set. de 2004
Eu fiz desse jeito aki ó ..
e deu certo ...
Esta é a classe responsável por verificar as portas seriais ...
import java.util.Enumeration ;
import javax.comm.* ;
public class SerialSupport & # 123 ;
public Enumeration listPortChoices & # 40 ; & # 41 ; & # 123 ;
CommPortIdentifier portId ;
Enumeration en = CommPortIdentifier . getPortIdentifiers & # 40 ; & # 41 ;;
return en ;
& # 125 ;
& # 125 ;
Mostra em um combo box quais com´s estão disponíveis ...
import java.util.Enumeration ;
import javax.swing.JFrame ;
import javax.comm.* ;
import serial.SerialSupport ;
//--------------------------------------------------------------------------//
// Autor:Felipe Cunha //
// Data:06/09/2004 //
// //
// controleRemotoView
public class SerialConfig extends JFrame & # 123 ;
static CommPortIdentifier portId ;
Enumeration en = null ;
SerialSupport serialsupport = new SerialSupport & # 40 ; & # 41 ;;
private javax . swing . JPanel jContentPane = null ;
private javax . swing . JComboBox jComboBox = null ;
private javax . swing . JLabel jLabel = null ;
/**
* This is the default constructor
*/
public SerialConfig & # 40 ; & # 41 ; & # 123 ;
super & # 40 ; & # 41 ;;
initialize & # 40 ; & # 41 ;;
& # 125 ;
/**
* This method initializes this
*
* @return void
*/
private void initialize & # 40 ; & # 41 ; & # 123 ;
this . setSize & # 40 ; 258 , 200 & # 41 ;;
this . setContentPane & # 40 ; getJContentPane & # 40 ; & # 41 ; & # 41 ;;
this . setVisible & # 40 ; true & # 41 ;;
& # 125 ;
/**
* This method initializes jContentPane
*
* @return javax.swing.JPanel
*/
private javax . swing . JPanel getJContentPane & # 40 ; & # 41 ; & # 123 ;
if & # 40 ; jContentPane == null & # 41 ; & # 123 ;
jContentPane = new javax . swing . JPanel & # 40 ; & # 41 ;;
jContentPane . setLayout & # 40 ; null & # 41 ;;
jContentPane . add & # 40 ; getJComboBox & # 40 ; & # 41 ;, null & # 41 ;;
jContentPane . add & # 40 ; getJLabel & # 40 ; & # 41 ;, null & # 41 ;;
& # 125 ;
return jContentPane ;
& # 125 ;
/**
* This method initializes jComboBox
*
* @return javax.swing.JComboBox
*/
private javax . swing . JComboBox getJComboBox & # 40 ; & # 41 ; & # 123 ;
if & # 40 ; jComboBox == null & # 41 ; & # 123 ;
jComboBox = new javax . swing . JComboBox & # 40 ; & # 41 ;;
jComboBox . setBounds & # 40 ; 32 , 61 , 146 , 19 & # 41 ;;
en = serialsupport . listPortChoices & # 40 ; & # 41 ;;
while & # 40 ; en . hasMoreElements & # 40 ; & # 41 ; & # 41 ; & # 123 ;
portId = & # 40 ; CommPortIdentifier & # 41 ; en . nextElement & # 40 ; & # 41 ;;
if & # 40 ; portId . getPortType & # 40 ; & # 41 ; == CommPortIdentifier . PORT_SERIAL & # 41 ; & # 123 ;
jComboBox . addItem & # 40 ; portId . getName & # 40 ; & # 41 ; & # 41 ;;
& # 125 ;
& # 125 ;
& # 125 ;
return jComboBox ;
& # 125 ;
/**
* This method initializes jLabel
*
* @return javax.swing.JLabel
*/
private javax . swing . JLabel getJLabel & # 40 ; & # 41 ; & # 123 ;
if & # 40 ; jLabel == null & # 41 ; & # 123 ;
jLabel = new javax . swing . JLabel & # 40 ; & # 41 ;;
jLabel . setBounds & # 40 ; 15 , 20 , 233 , 29 & # 41 ;;
jLabel . setText & # 40 ; & quot ; Soh pra debug , mostra a com q está disponível & quot ; & # 41 ;;
& # 125 ;
return jLabel ;
& # 125 ;
& # 125 ; // @jve:visual-info decl-index=0 visual-constraint="10,10"