Problems in editable Combo Box

Hello,
I have an editable Combo Box and an action listener associated with the Combo Box. I also have a "Store" button that stores the edited item in the Combo Box and an action listener associated with the button too. After I have selected an item in the Combo Box and edited it, I press the "Store Button". Instead of going to the Store_button_action performed method, it goes to the ComboBox_action performed method and after running it, it stops. Which means it does not run the Store_button_action performed method at all.
Another thing I have noticed is that when ever I select any item from this Combo Box it gets highlighted in blue, is there some way around this? I want the cursor to be blinking at the beginning/end of the selected Item.
Thanks and regards,
Ibha

Hi,
you can use a Textfield as editor component for a ComboBox:
create a class implementing javax.swing.ComboBoxEditor with an attribute type Textfield. This TextField uses your PlainDocument.
In getEditorComponent() you return the TextField.
Hope this helps,
Phil

Similar Messages

  • Event problem in editable combo box

    I have three editable combo box in my JDialog. I can select the value from the combo or I can enter any value. I have to perform some operation when one button is pressed after I have given the values in the three combo boxes. Here, If I select any value from the combo box, there is no problem. But if I enter the value in the combo boxes, when I press the button, in the first click nothing is happening. The First click just selects the value that entered in the last combo box and in the second click it works properly. I am not facing this problem in JDK 1.2.2 or JDK1.3. This occurs only in JDK1.4. Please let me if anyone knows the reason for this.
    Thanks.

    in the fla that contains your loadMovie() statement:
    1. drag a combobox to the stage.
    2. remove it.
    3. the combobox component will now be in your library.
    re-publish your swf and retest.

  • Problem with editable combo box and creating dynamic table values using js

    Hai
    I have used jquery.jec.js to make my dropdown list as editable... I need to create dynamic table values on the onChange event of dropdown using javascript.
    Now am facing the problem in it...
    I am getting duplicate rows in the table... think(assumption) this jquery.jec.js is calling the dropdown again creating duplicate values...
    Please help me out.... Any help is appreciable... Thanks in advance

    Thanks elOpalo, for your valuable response....
    I have found the correct way of doing.
    Before i had my code like this,
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>test</title>
    <script type="text/javascript" src="js/jquery-latest.js"></script>
    <script type="text/javascript" src="js/jquery.jec.js"></script>
    <script type="text/javascript">
    $(function(){
    $('#list').jec();
    function giveAlert(){
         alert('hello');
    </script>
    </head>
    <body>
    <form>
    Combo Box:
    <select id="list" name="list" onChange="giveAlert();">
    <option value="1">one</option>
    <option value="2">two</option>
    </select>
    </form>
    </body>
    </html>
    Now i have changed as the following,
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>test</title>
    <script type="text/javascript" src="js/jquery-latest.js"></script>
    <script type="text/javascript" src="js/jquery.jec.js"></script>
    <script type="text/javascript">
    $(function(){
    $('select.combo').jec();
    $('select.combo')
    .change(function() {
    alert($(this).val());
    }).change();
    </script>
    </head>
    <body>
    <form>
    <table>
    <tr>
    <td>Combo Box:</td>
    <td><select class="combo"><option value="b">banana</option><option value="a">apple</option></select></td>
    </tr>
    </table>
    </form>
    </body>
    </html>
    The problem is with the function i have called on the onChange Event.. Now i have defined it inside the jquery function of dropdown to make it as editable...

  • Editable combo box - changing list

    hey all,
    I have to capture a code, which may be one of many types, and have planned on using an editable combo box, which narrows down the available options as the user types into it - as many programs use.
    Problem is that I'm not sure what it is I need to do to make this work. So far I've got my own ComboBoxModel implementation, and I had tried listening to edit changes, and changing the list based on that. Problem is I cant mutate in the middle of the notification, so no luck there.
    Anyone have any ideas how to make this work?
    cheers
    dim

    ttarola:
    I'm not sure if I've misinterpreted your advice, but I couldn't get it to work... here's what I've done:
    public class TestKeyListener extends KeyAdapter
      private int lastItemIndex = -2;
      private final JComboBox comboBox;
      public TestKeyListener(JComboBox comboBox)
        this.comboBox = comboBox;
       * Invoked when a key has been released.
       * As you are typeing in this field it tries to help you to coomplete the
       * expression you are looking for.
      public void keyReleased(KeyEvent e)
        int keyCode = e.getKeyCode();
        JTextField editBox = (JTextField) comboBox.getEditor().getEditorComponent();
        String typedText = editBox.getText();
        int typedTextLength = typedText.length();
        // nothing has been written
        if (typedTextLength == 0)
          comboBox.setSelectedItem("");
          return;
        boolean isDelete = ((keyCode == e.VK_DELETE) || (keyCode == e.VK_BACK_SPACE));
        if (isDelete || (e.getKeyText(keyCode).length() == 1))
          String item;
          for (int i = 0; i < comboBox.getItemCount(); i++)
            item = comboBox.getItemAt(i).toString();
            if (item.startsWith(typedText))
              // after deleting the same item is the actual one
              if (isDelete && lastItemIndex == i)
                return;
              lastItemIndex = i;
              comboBox.setSelectedIndex(lastItemIndex);
              editBox.setText(item);
              editBox.setCaretPosition(typedTextLength);
              editBox.select(typedTextLength, item.length());
              return;
      public static void main(String[] args)
        final JFrame frame = new JFrame("test2");
        frame.addWindowListener(new WindowAdapter()
          public void windowClosing(WindowEvent ev)
            frame.dispose();
            System.exit(0);
        JComboBox comboBox = new JComboBox();
        for (int j = 0; j < 50; j++)
          if (j % 10 == 0) comboBox.addItem("A" + j / 10 + "77" + j);
          if (j % 10 == 1) comboBox.addItem("B" + j / 10 + "77" + j);
          if (j % 10 == 2) comboBox.addItem("C" + j / 10 + "77" + j);
          if (j % 10 == 3) comboBox.addItem("D" + j / 10 + "77" + j);
          if (j % 10 == 4) comboBox.addItem("E" + j / 10 + "77" + j);
        comboBox.setEditable(true);
        comboBox.addKeyListener(new TestKeyListener(comboBox));
        frame.setBounds(1, 1, 500, 300);
        frame.getContentPane().setLayout(new FlowLayout());
        frame.getContentPane().add(comboBox);
        frame.setVisible(true);
    }this doesn't really bother me, as the other poster has solved my problem (see next post)...
    cheers
    dim
    cheers
    dim

  • Editable Combo box in a JTable

    Hi,
    Is it possible to have an editable combo Box in a JTable with an item Listener attached to the combo Box?
    Based on whatever value the user enters in that column that is rendered as a combo Box(editable) i should be able to do some validation. Is this possible?
    Thanks in advance for your time and patience.
    Archana

    Here's a start:
    public class FileModel5 extends AbstractTableModel
    public boolean isEditable = false;
    protected static int NUM_COLUMNS = 3;
    // initialize number of rows to start out with ...
    protected static int START_NUM_ROWS = 0;
    protected int nextEmptyRow = 0;
    protected int numRows = 0;
    static final public String file = "File";
    static final public String mailName = "Mail Id";
    static final public String postName = "Post Office Id";
    static final public String columnNames[] = {"File", "Mail Id", "Post Office Id"};
    // List of data
    protected Vector data = null;
    public FileModel5()
    data = new Vector();
    public boolean isCellEditable(int rowIndex, int columnIndex)
    // The 2nd & 3rd column or Value field is editable
    if(isEditable)
    if(columnIndex > 0)
    return true;
    return false;
    * JTable uses this method to determine the default renderer/
    * editor for each cell. If we didn't implement this method,
    * then the last column would contain text ("true"/"false"),
    * rather than a check box.
    public Class getColumnClass(int c)
    return getValueAt(0, c).getClass();
    * Retrieves number of columns
    public synchronized int getColumnCount()
    return NUM_COLUMNS;
    * Get a column name
    public String getColumnName(int col)
    return columnNames[col];
    * Retrieves number of records
    public synchronized int getRowCount()
    if (numRows < START_NUM_ROWS)
    return START_NUM_ROWS;
    else
    return numRows;
    * Returns cell information of a record at location row,column
    public synchronized Object getValueAt(int row, int column)
    try
    FileRecord5 p = (FileRecord5)data.elementAt(row);
    switch (column)
    case 0:
    return (String)p.file;
    case 1:
    return (String)p.mailName;
    case 2:
    return (String)p.postName;
    catch (Exception e)
    return "";
    public void setValueAt(Object aValue, int row, int column)
    FileRecord5 arow = (FileRecord5)data.elementAt(row);
    arow.setElementAt((String)aValue, column);
    fireTableCellUpdated(row, column);
    * Returns information of an entire record at location row
    public synchronized FileRecord5 getRecordAt(int row) throws Exception
    try
    return (FileRecord5)data.elementAt(row);
    catch (Exception e)
    throw new Exception("Record not found");
    * Used to add or update a record
    * @param tableRecord
    public synchronized void updateRecord(FileRecord5 tableRecord)
    String file = tableRecord.file;
    FileRecord5 p = null;
    int index = -1;
    boolean found = false;
    boolean addedRow = false;
    int i = 0;
    while (!found && (i < nextEmptyRow))
    p = (FileRecord5)data.elementAt(i);
    if (p.file.equals(file))
    found = true;
    index = i;
    } else
    i++;
    if (found)
    { //update
    data.setElementAt(tableRecord, index);
    else
    if (numRows <= nextEmptyRow)
    //add a row
    numRows++;
    addedRow = true;
    index = nextEmptyRow;
    data.addElement(tableRecord);
    //Notify listeners that the data changed.
    if (addedRow)
    nextEmptyRow++;
    fireTableRowsInserted(index, index);
    else
    fireTableRowsUpdated(index, index);
    * Used to delete a record
    public synchronized void deleteRecord(String file)
    FileRecord5 p = null;
    int index = -1;
    boolean found = false;
    int i = 0;
    while (!found && (i < nextEmptyRow))
    p = (FileRecord5)data.elementAt(i);
    if (p.file.equals(file))
    found = true;
    index = i;
    } else
    i++;
    if (found)
    data.removeElementAt(i);
    nextEmptyRow--;
    numRows--;
    fireTableRowsDeleted(START_NUM_ROWS, numRows);
    * Clears all records
    public synchronized void clear()
    int oldNumRows = numRows;
    numRows = START_NUM_ROWS;
    data.removeAllElements();
    nextEmptyRow = 0;
    if (oldNumRows > START_NUM_ROWS)
    fireTableRowsDeleted(START_NUM_ROWS, oldNumRows - 1);
    fireTableRowsUpdated(0, START_NUM_ROWS - 1);
    * Loads the values into the combo box within the table for mail id
    public void setUpMailColumn(JTable mapTable, ArrayList mailList)
    TableColumn col = mapTable.getColumnModel().getColumn(1);
    javax.swing.JComboBox comboMail = new javax.swing.JComboBox();
    int s = mailList.size();
    for(int i=0; i<s; i++)
    comboMail.addItem(mailList.get(i));
    col.setCellEditor(new DefaultCellEditor(comboMail));
    //Set up tool tips.
    DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
    renderer.setToolTipText("Click for mail Id list");
    col.setCellRenderer(renderer);
    //Set up tool tip for the mailName column header.
    TableCellRenderer headerRenderer = col.getHeaderRenderer();
    if (headerRenderer instanceof DefaultTableCellRenderer)
    ((DefaultTableCellRenderer)headerRenderer).setToolTipText(
    "Click the Mail Id to see a list of choices");
    * Loads the values into the combo box within the table for post office id
    public void setUpPostColumn(JTable mapTable, ArrayList postList)
    TableColumn col = mapTable.getColumnModel().getColumn(2);
    javax.swing.JComboBox combo = new javax.swing.JComboBox();
    int s = postList.size();
    for(int i=0; i<s; i++)
    combo.addItem(postList.get(i));
    col.setCellEditor(new DefaultCellEditor(combo));
    //Set up tool tips.
    DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
    renderer.setToolTipText("Click for post office Id list");
    col.setCellRenderer(renderer);
    //Set up tool tip for the mailName column header.
    TableCellRenderer headerRenderer = col.getHeaderRenderer();
    if (headerRenderer instanceof DefaultTableCellRenderer)
    ((DefaultTableCellRenderer)headerRenderer).setToolTipText(
    "Click the Post Office Id to see a list of choices");
    }

  • Editable combo box

    I have copied the code for editable combo box. This includes "samples" package. Could anyone guide me where i can get the package in java.sun.com. I am new to java and trying to design a form with editable combo box. Obviously im getting the error "package samples.accessory does not exist". I have searched for accessory class but failed.
    Thanks in advance.

    Or, if the OP doesn't have access to your C drive, from here:I'm glad somebody knows what I'm talking about. :-)

  • SUD Dialog - Vorgabewerte in einer Edit/Combo-Box - Anzeigen von Werten die in einem vorgehendem Durchlauf eingeben wurden

    Ziel ist es in einem SUD Dialog Vorgabewerte in einer Edit/Combo-Box anzeigen zu lassen, um diese Daten nicht bei jedem Aufruf der Autosequenz neu eingeben zu müssen. Sie sollen aber nicht in einer List-Box ausgewählt werden, sondern in einer Edit/combo-Box. Als Vorgabewerte sollten die zuletzt bei einem Durchlauf der Autosequenz eingegebenen Werte oder Texte in dem Fenster der Box erscheinen. Könnte man hier Variablen verwenden? Müssen diese in dem static Fenster eingegeben werden, bzw. mit welcher Befehlszeile?
    Sub EditBox5_EventInitialize()
    Dim This : Set This = EditBox5
    End Sub
    Wir verwenden noch DIAdem 8.0

    Hallo Herr Gutknecht,
    Sie koennen eine DIAdem VAS-Variable von Typ "A" oder "G" benutzen und diese der Combobox als zugehoerige Variable zuweisen. Die moeglichen Werte der "A" oder "G" Variable bleiben von SUD-Start zu SUD-Start in DIAdem erhalten, sowie auch der zuletzt-gewaehlte Wert der Variable. Beim naechsten SUD-Start wird dieser zuletz-gewaehlte Wert in der Combobox dargestellt.
    Mit schoenen Gruessen,
    Brad Turpin
    DIAdem Product Support Engineer (USA)
    National Instruments

  • Problems with a combo box in dynpro

    Hi guys, im creating a combo box in a dynpro, but is not showing anything.
    the code is the following:
    AT the screen painter..
    MODULE USER_COMMAND_0100.
       PROCESS ON VALUE-REQUEST.
      FIELD TI_COMBO MODULE create_dropdown_box.
    *then the module in the main program.....
    module create_dropdown_box input.
    TYPES: BEGIN OF type_carrid,
             op1(20),
             ID TYPE N,
           END OF type_carrid.
    DATA ti_combo TYPE STANDARD TABLE OF type_carrid WITH HEADER LINE.
    ti_combo-op1 = 'Not processed'.
    TI_COMBO-ID = 1.
    append ti_combo.
    ti_combo-op1 = 'Duplicated.
    append ti_combo.
    ti_combo-op1 = 'For Payroll'.
    append ti_combo.
      CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
           EXPORTING
            RETFIELD = 'ID'
            DYNPPROG = SY-REPID
            DYNPNR = '100'
            DYNPROFIELD = 'TI_COMBO'
            VALUE_ORG = 'S'
           TABLES
                value_tab       = ti_combo
           EXCEPTIONS
                parameter_error = 1
                no_values_found = 2
                OTHERS          = 3.
      IF sy-subrc <> 0.
      ENDIF.
    endmodule.
    Edited by: javier  santana on May 7, 2008 5:47 PM

    Hi,
    Check the below code.
    TYPE-POOLS: VRM.
    DATA:V_NUM TYPE I.
    DATA:NAME TYPE VRM_ID,
         LIST TYPE VRM_VALUES,
         VALUE LIKE LINE OF LIST.
    DATA:I_WORKPATTERN LIKE ZWORKPAT OCCURS 0 WITH HEADER LINE.
    DATA:ZPATTXT(60).
    MODULE WORKPATTERN_LISTBOX OUTPUT.
    NAME = 'P9434-ZWORKPATTERN'.
        IF V_NUM IS INITIAL.
        CLEAR I_WORKPATTERN.
        REFRESH I_WORKPATTERN.
        SELECT *
               FROM ZWORKPAT
               INTO TABLE I_WORKPATTERN.
        IF NOT I_WORKPATTERN[] IS INITIAL.
          LOOP AT I_WORKPATTERN.
            VALUE-KEY = I_WORKPATTERN-ZWORKPATTERN.
            VALUE-TEXT = I_WORKPATTERN-ZWORKPATTERN.
            APPEND VALUE TO LIST.
          ENDLOOP.
        ENDIF.
        CALL FUNCTION 'VRM_SET_VALUES'
          EXPORTING
            ID                    = NAME
            VALUES                = LIST
         EXCEPTIONS
           ID_ILLEGAL_NAME       = 1
           OTHERS                = 2.
        IF SY-SUBRC <> 0.
          CLEAR SY-SUBRC.
        ENDIF.
        V_NUM = V_NUM + 1.
        ENDIF.

  • Problem rendering a combo box in the data grid

    Hi,
    I am rendering a combo box in the data grid control using an
    item renderer. When I click on it to select a value from the drop
    down, the combo box immediately closes giving no time to even click
    on the dropdown. This doesn’t happen every time the combo is
    clicked, although it happens frequently. What I think is that the
    problem arises because the data grid tries to refresh the renderers
    and during this process, the existing combo is removed, thereby
    getting closed automatically. Please let me know of a work around.
    Thanks,
    Cheree

    hi hiwa,
    i have to add combo box in datagrid dynamically.
    it should append as and when i add the data in the above text boxes.
    thanks in advance.

  • Problem in showing combo box in the table

    Hello guys i just add up the combo box in the table but the problem is when i change the line in the table the combo disappear. i want it to be visible even if it is not in the selected row. i want that user can see the combo box in the table without clicking on it.
    Please help;

    http://java.sun.com/docs/books/tutorial/uiswing/components/table.html
    Look in the page bottom !

  • JSP problem - drop down combo boxes

    Hi,
    I want to load a database table value into my HTML form's dropdown combo box.
    Actually I want to do this. I need to change employee information. To do this there is a form to enter empNo. Then it will display a .jsp page with the relevant fields of that employee. In this .jsp page, it has a drop down combo box for title. In my db the required title of that employee is Miss.
    But how could I display this value in this dropdown combo box. Then the user can change it as she wish.
    I try it like this way, but it isn't work.
    <select size="1" name="title" style="border: 1px solid #0000FF">
           <jsp:getProperty name="candidate" property="title" />
    </select>     Can anybody tell me hoe to solve this?
    Thanks.

    Hi,
    Thanks for your help.
    I have change that code, as follows.
    <select size="1" name="title" style="border: 1px solid #0000FF">
    <option value="" ><jsp:getProperty name="candidate" property="title" /></option>
    </select> Now it displays the correct title. But how can I display the other 2 options below this? that is Mr. and Mrs. Because the user must have the facility to select Miss. or Mrs. if there any changes she wish to apply.
    Note:
    If a user has a title - Mr. , then the other 2 titles (Miss,Mrs) should be display below it.
    How to solve this?
    Thanks

  • Edit combo box array

    Hello,
    I am trying to add a value to a specific combo box in a 2d array.
    lets say i have a 2d array of combo boxes, how can i add a value to the combo box in row 3 and colomn 4?
    Thank.

    Hey,
    I have an ini file with diffrent tests and every test has a diffrent settings, for example:
    [HO type_Intra ASN Handover]
    Type=INI VI
    Delay between H.O=5,2
    Trafic type=Smartbits,Ping
    Number of Handover=xxx
    [HO type_Inter ASN Handover]
    Type=INI VI
    Deleay between H.O=5,2
    Trafic type=Smartbits,Ping
    Number of Handover=xxx
    The idea is that for example delay between handovers is a combo box parameter with values of 5,2 and trafic type is also a combo box parameter but with values smartbit or ping and the number of handovers is a regular string how can i diplay those parameter for the user ? there can be more then 3 parameter...is there a solution ?

  • Combo Box Edits in acrobat Forms, how to do a multi-line combo box?

    Could only create a one-liners for this editable combo box, is there a way to create a multi-line like the other fields?

    Nope. But you can set up a multiline text field that gets populated with the complete text you want when an item is selected from a combo box.The combo box items might be abbreviated or coded versions of the complete text you want to display.

  • Long strings in combo box

    I have an editable combo box that I'm sticking in a compact spring layout. The problem is if you use a list that contains very long strings (like a long hex string), the combo box sizes itself to fit it and all the other controls are made to be that length as well. Is there a way to stop the control from becoming so long, like a horizontal scroll bar in the list?

    Read this [url http://www.objects.com.au/java/examples/src/examples/SteppedComboBoxExample.java]example
    Here's its [url http://www.objects.com.au/java/examples/swing/SteppedComboBox.do]picture
    ICE

  • Combo box vs Dropdown list

    The Java Studio Creator (2004Q2, Update 8) help screen says that �Dropdown lists are the same as combo boxes in Swing and Microsoft Windows.�
    According to a SUN Java Swing web page, �Combo boxes require little screen space, and their editable (text field) form is useful for letting the user quickly choose a value without limiting the user to the displayed values.�
    How does one get the Combo box functionality (i.e. editable text field) in Dropdown lists in Creator?
    Thank you.

    Hi,
    Combo boxes are of two types, editable and non editable. Reference to this can be found at:
    http://java.sun.com/products/jfc/tsc/articles/jlf/index.html
    The dropdown list component provided in Creator is a non editable combo box. Also please refer to the Writing custom components for Creator by Edwin Goei available at:
    http://wiki.java.net/bin/view/Javatools/SunJavaStudioCreator
    Hope this helps
    Cheers
    Giri

Maybe you are looking for

  • IPhoto onto External Hard drive

    I am trying to be able to completely remove iPhoto from my internal hard drive and move it to my external hard drive. I have over 8000 and have no plan on stopping soon I want to be able to open iPhoto from my external hard drive and see my sorted fo

  • C# - How to get the name of account (i have 3 accounts configured at Outlook) when I receive an email?

    At my Outlook 2013 I have 3 different accounts configured (two personal and 1 professional). When I receive an email at real time I need to know which account the mail is addressed, because I only want to work with the professional account! I use out

  • 1/4" with optical audio output

    Does anyone actually use the digital audio output? Like in a home theater for Dolby Digital? Does the MBP output DTS?

  • 23" vs 30" Monitor

    I know I asked in an earlier post about the difference in these two monitors, however now I am thinking about getting the 30" instead of the 23". If there is anyone who could advise me which way to go I would be greatly appreciative for your input. T

  • How to position bookmarks

    Hi, My Bookmarks show only in the left pane of my Browser. How to move them to the right side? Thank you barsim