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. :-)

Similar Messages

  • 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 - 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

  • 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 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

  • 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...

  • 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.

  • 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

  • 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

  • Edit Items in TestStand Sequence File Combo Box?

    Hello All,
      I am creating a basic user interface VI Project, based off of the examples included with TestStand.  In the "Simple" example, there is a Open Seq File button, and an associated combo box to select the Sequence File to run.  For my application, I would like to limit the sequence file options from which the operator can choose (not allow the operator to browse the entire hard drive to find a sequence file).  Using basic Labview functions, I would have done this with a regular combo box, and use the "Edit Items" option to load file options into the drop-down menu.  However, the TestStand UI combo box does not allow this, presumably because it is an ActiveX control, and configuration is different from normal Labview functions.  Is it possible to pre-load the TestStand UI combo box with allowed sequence files?  Or, if there are other suggestions on how to accomplish the requirement, I am open to them as well. 
    Thanks in advance,
    GSinMN       

    One idea is to use the native LabVIEW controls.  Then hide the TestStand UI controls and update them from the events triggered by the native LabVIEW controls. I have had to do this before on UIs when the customer wanted a certain look and feel.
    So basically have the native LabVIEW combo box set like you want.  When the user makes a selection, in the event for that selection update the hidden TestStand Sequence File Combo Box witht he correct sequence file.
    Another option is to use events for the Sequence File Combo Box and just filter and force certain behavior.
    Hope this helps,
    jigg
    CTA, CLA
    teststandhelp.com
    ~Will work for kudos and/or BBQ~

  • In edit mode, can't select specific options in combo box

    I need to edit options in a combox box.  When I click on the option I want to edit, it's actually reflected in the combo box, but the option I selected doesn't stay highlighted for editing. The highlight jumps to a different option. This is consistent, but not all options jump.  I can't edit many of the options. Using Acrobat 9 Pro.
    Any suggestions? 

    try67 says..."It's not necessary to use Acrobat 5 to edit form fields. Acrobat 9 can do it just fine."
    For the most part, A5 and A9 field editing process is the same.  Editing the combox box properties is EXACTLY the same. Open the combo box field properties, select the options tab. Click on the option you want to change. The text shows up in the upper window. Edit the text. Save the edited option. It goes to the bottom, Then run it up to where it goes in the list and delete the prior option.   In Acrobat 9 (on two machines in our office) the item you click on does not stay selected. The job at hand has a list of 33 options, some stay selected, some do not and are impossible to select...even to delete.
    In Acrobat 5, this same process works perfectly.
    I'm quite sure that anyone serious (aka trying to make money) about Acrobat production keeps a copy of A5 on hand.  Try setting tab order in V9 on a 900 field form that requires a mix of column and row ordering. Then go to the window at the left and pick a field and try to run it up to where it goes. The window doesn't even scroll.  You have to set your field down, scroll the window and pick it up and go another jag. And then, scroll back down and try to find your place to pick up the next field. In A5, you simply click the fields on the form in the order you want them.  10 minutes vs. 2 hours.
    This is not "just fine".

  • Cant edit items in combo box

    I cannot edit items in my combo box when i click on it. I just see whit box . Can anybody help me ? 

    Dear Skooty,
    in such cases, as the previous poster had said, recreating the control/VI in question usually fixes the problem. If it persists, a repair of your LabVIEW installation might be necessary.
    Please let us know of your results.
    Regards,
    Andrew Valko
    National Instruments Hungary

  • How to edit items of a combo box that is part of an array of clusters

    Hi,
    In the attached vi, I have an array of clusters, and each cluster contain two combo boxes. How do I edit the items in Combo Box 1 for all elements of the array? (All Combo Box 1 elements shall include the same items.)
    For illustration, I also included the trivila case, i.e., editing the items in a separate combo box that is is not part of an array of clusters (Combo Box 3). Please advise. Thanks.
    Peter
    Solved!
    Go to Solution.
    Attachments:
    Question Combo Box in Array of Clusters.vi ‏16 KB

    Please mark S_Mercurio's message as the solution to your question rather than your own thank you  message.  First you will have to unmark  yours by going to the option menu to the upper right of your message.

Maybe you are looking for

  • Itunes won't open. says error report

    everytime i click on itunes a window comes up saying "iTunes has encountered a problem and needs to close. we are sorry for the inconvenience." then at the buttom there are two links sayind SEND ERROR REPORT and DON'T SEND. clicking either one won't

  • Firefox will not open to home page as directed in options and settings. Opening in safe mode makes no difference, either. Any ideas?

    Firefox will not open to home page as set in the settings. Even in safe mode, it still will not open to home page as directed. It seems to want to open to last set of tabs, even though that is not the way it was set in settings. It seems as though th

  • WINDOWS UPDATE FREEZE in a blank screen for ever

    8 days ago I bought a new HP ALL IN ONE COMPUTER  PAVILION 23 . It work well for 8 days ; so on the 9 day i notice the Mc Afee antivirus  will expired in one motnh . Then I bought on line the offer of Mc Afee for one year and acticated . Then on the

  • Available paper sizes have changed

    My printer isn't showing me the normal paper size options. In Page Setup of any application, I click the Format For popup and choose my printer (Brother HL-5250DN), but in the Paper Size popup the normal paper sizes aren't showing. I used to see Lett

  • Sequence Settings: 1920 footage is changed to 1440

    I'm importing footage from my Canon T2i shot at 1920x1080 24fps. There are no other sources for the sequence. I dragged clips into the timeline and now the sequence is set to 1440x1080. Furthermore, I don't see any options to change it to 1920x1080 i