Results 1 to 2 of 2
- 09-20-2011, 04:19 PM #1
Member
- Join Date
- Jul 2011
- Posts
- 27
- Rep Power
- 0
How to read existing Value from a combobox.
Hi Guys,
I am new to java. I am working on a Java Serialport configuration Project. I am able connect to a serial port.But need help to configure a serial port. I do have a combobox which have some parameters baud rate. If I click to set a new serial port or baud rate combobox It suppose to be show me current setting what ever existing and then I have to change.I just want to know how to see existing setting in a cobobox. Please respond my forum.
public String getPortList()
{
return (String) cmbPortList.getSelectedItem();
}
public int getbaudrate()
{
return Integer.parseInt(cmbBaudrate.getSelectedItem().toS tring());
}
public int getstopbits()
{
int stopbits= cmbStop.getSelectedIndex();
switch(stopbits)
{
case 0:
return SerialPort.STOPBITS_1;
// break;
case 1:
return SerialPort.STOPBITS_1_5;
//break;
case 2:
return SerialPort.STOPBITS_2;
// break;
default:
return SerialPort.STOPBITS_1;
// break;
}
}
public int getParity()
{
int parity = cmbParity.getSelectedIndex();
switch (parity)
{
case 0:
return SerialPort.PARITY_NONE;
//break;
case 1:
return SerialPort.PARITY_EVEN;
//break;
case 2:
return SerialPort.PARITY_ODD;
//break;
case 3:
return SerialPort.PARITY_MARK;
//break;
case 4:
return SerialPort.PARITY_SPACE;
//break;
default:
return SerialPort.PARITY_NONE;
//break;
}
}
public int getdatabits()
{
int data= cmbData.getSelectedIndex();
switch (data)
{
case 0:
return SerialPort.DATABITS_5;
// break;
case 1:
return SerialPort.DATABITS_6;
// break;
case 2:
return SerialPort.DATABITS_7;
// break;
case 3:
return SerialPort.DATABITS_8;
// break;
default:
return SerialPort.DATABITS_8;
// break;
}
}
public int getflowcontrol()
{
int flowcontrol = cmbFlowcontrol.getSelectedIndex();
switch(flowcontrol)
{
case 0:
return SerialPort.FLOWCONTROL_NONE;
//break;
case 1:
return SerialPort.FLOWCONTROL_XONXOFF_IN;
//break;
case 2:
return SerialPort.FLOWCONTROL_RTSCTS_IN;
//break;
case 3:
return SerialPort.FLOWCONTROL_NONE;
//break;
}
return SerialPort.FLOWCONTROL_NONE;
}
- 09-20-2011, 04:31 PM #2
Re: How to read existing Value from a combobox.
How to Ask Questions the Smart Way
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!
Similar Threads
-
how to put existing file in ftp
By trkece in forum NetworkingReplies: 0Last Post: 02-11-2011, 05:42 AM -
JOptionPane with a comboBox with data read from a text file
By rdmapes in forum AWT / SwingReplies: 0Last Post: 11-21-2010, 05:10 PM -
Get CSS/ Use existing CSS
By karthikeyan_raju in forum JavaServer Pages (JSP) and JSTLReplies: 1Last Post: 10-21-2009, 05:24 PM -
how to add GUI to existing program?
By VinTiger in forum New To JavaReplies: 2Last Post: 05-08-2009, 05:05 AM -
java.io.IOException: Unable to read entire block; 493 bytes read before EOF; expected
By kushagra in forum New To JavaReplies: 5Last Post: 10-17-2008, 02:13 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks