Results 1 to 2 of 2
  1. #1
    Khan05 is offline Member
    Join Date
    Jul 2011
    Posts
    27
    Rep Power
    0

    Default 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;
    }

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is online now Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,939
    Rep Power
    8

    Default 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

  1. how to put existing file in ftp
    By trkece in forum Networking
    Replies: 0
    Last Post: 02-11-2011, 05:42 AM
  2. Replies: 0
    Last Post: 11-21-2010, 05:10 PM
  3. Get CSS/ Use existing CSS
    By karthikeyan_raju in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 10-21-2009, 05:24 PM
  4. how to add GUI to existing program?
    By VinTiger in forum New To Java
    Replies: 2
    Last Post: 05-08-2009, 05:05 AM
  5. Replies: 5
    Last Post: 10-17-2008, 02:13 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •