JComboBox autocomplete problem

hi all. I would like to know a, quick, easy and simple technique to have auto complete function in JComboBox.
I know this question about autocomplete has been answered several times in this forum. But all of them give some complex custom made codes.
Since this is a very nice feature in Windows, doesnt Java provide support for this in one of its API?
I have gone through the documentation also to find whether this function has been already implemented. Apparently, I could not find such support. Could anyone please give me any guidance.
thanks.

If Java supported this in the standard API's, then you wouldn't find "complex custom made codes" around here, you'd find people telling others to check out this or that class or method.

Similar Messages

  • JCombobox selection problem

    Hello,
    I have some problem implementing events associated with JComboBox. My requirement is "the event should get fired only when an item is selected in the combobox". It may occur thet using arrow keys I can traverse all elements in the combobox and on item change the event should not get fired. I tried with itemstatechanged, actionperformed but no result.
    Any help will be appreciated.
    regards,
    Ranjan

    A simple working example:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.text.*;
    public class ComboBoxAction extends JFrame implements ActionListener
         private JComboBox comboBox;
         public ComboBoxAction()
              comboBox = new JComboBox();
              comboBox.addActionListener( this );
              comboBox.addItem( "Item 1" );
              comboBox.addItem( "Item 2" );
              comboBox.addItem( "Item 3" );
              comboBox.addItem( "Item 4" );
              //  This prevents action events from being fired when the
              //  up/down arrow keys are used on the dropdown menu
              comboBox.putClientProperty("JComboBox.isTableCellEditor", Boolean.TRUE);
              getContentPane().add( comboBox );
         public void actionPerformed(ActionEvent e)
              System.out.println( comboBox.getSelectedItem() );
              //  make sure popup is closed when 'isTableCellEditor' is used
              comboBox.hidePopup();
         public static void main(String[] args)
              JFrame frame = new ComboBoxAction();
              frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
              frame.pack();
              frame.setVisible( true );
    }

  • JcomboBox + FOR - problem

    Hi,
    I try changing this code:
    ArrayList<String> tmp = new ArrayList<String>();
    tmp.add(numbertext.getText());
    for(String temp1 : tmp)
    System.out.println("a="+temp1.toString());
    <b>
    Legend:
    </b>
    numbertext is a JtextField.for JComboBox using FOR but i have error and problems.
    String[] items = {"item1", "item2", "item3"};
    jComboBox1.setModel(new DefaultComboBoxModel(items));
    int num = jComboBox1.getItemCount();
    String my = Integer.toString(num);
    for (String s : my ) {
            Object item = jComboBox1.getItemAt(num);
            System.out.println("a="+s.toString());I don;t know how to translate for JComoboBox.
    Please help

    Hmmmm,
    I try creating code which I choose in JComoboBox1 value for example Items2 and I click the button. My first value Items2 will be include in string, next I choose value items 4 in JcomboBox and the second value will be in string. Now In string I have a 2 value: items 2 and items 4 And I will have doing choose new value to infinity.
    I don't now how to create.

  • JComboBox listener problem

    Hi all,
    I have following problem, i use combobox and i need to write listener for selecting item.
    But both ActionListener and ItemListener are unusable for me, because i dont know how to differ between selecting item when combobox is poped up.
    I dont want to react on going thru items in popup, but only to FINAL select of button.
    Please Help.
    Mathew, HSIGP

         This works on non editable combo boxes
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.text.*;
    public class ComboBoxAction extends JFrame implements ActionListener
         JComboBox comboBox;
         public ComboBoxAction()
              comboBox = new JComboBox();
              comboBox.addActionListener( this );
              comboBox.addItem( "Item 1" );
              comboBox.addItem( "Item 2" );
              comboBox.addItem( "Item 3" );
              comboBox.addItem( "Item 4" );
              //  This prevents action events from being fired when the
              //  up/down arrow keys are used on the dropdown menu
              comboBox.putClientProperty("JComboBox.isTableCellEditor", Boolean.TRUE);
              getContentPane().add( comboBox );
         public void actionPerformed(ActionEvent e)
              System.out.println( comboBox.getSelectedItem() );
              //  make sure popup is closed when 'isTableCellEditor' is used
              comboBox.hidePopup();
         public static void main(String[] args)
              final ComboBoxAction frame = new ComboBoxAction();
              frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
              frame.pack();
              frame.setVisible( true );
    }

  • JComboBox Render Problem........

    Hi I have a problem in JCombox renderer in my application Problem is i have Three comboBox columns in my table wing same Renderer and Editor. second and third combo column's aree working fine But in first combo-column if i add a new row clicking add button and if change a value in top- most comboBox i will reflect in all ComboBox's below, this is not happening in othe two Combo-column. i'am not at all gettin why this happens where i am using same renderer for all combo-columns how to stop this, When a new row is add ComboBox first item as Selected,
    Can any one please tell me how to solve this,
    since i cannot past entair application i am pasting example with similar suituation using same renderer.
    Thank's in Advance
    CODE:-
    import java.awt.BorderLayout;
    import java.awt.Component;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.DefaultCellEditor;
    import javax.swing.JButton;
    import javax.swing.JComboBox;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.JTable;
    import javax.swing.table.DefaultTableModel;
    import javax.swing.table.TableCellRenderer;
    import javax.swing.table.TableColumn;
    * @author 501376972
    public class MainTable extends JFrame{
    DefaultTableModel model = null;
    JTable table = null;
    JScrollPane scrollpane = null;
    JButton btCancel = null;
    JButton btADD = null;
    JPanel panelButton = null;
    public Object[][] data = null;
    String column[] = {" ","A","B","C","D","E","F"};
    String oprator[] = {" ","=","/","*","-","+"};
    String number[] = {" ","1","2","3","4","5","6"};
    /** Creates a new instance of MainTable */
    public MainTable() {
    model = new DefaultTableModel();
    model.addColumn("Column");
    model.addColumn("Operator");
    model.addColumn("Value");
    model.addColumn("Number");
    table = new JTable();
    table.setModel(model);
    data = new Object[][]{
    {column, oprator, null, number}
    model.addRow(data);
    TableColumn colCol = table.getColumnModel().getColumn(0);
    colCol.setCellRenderer(new ComboBoxCellRenderer(column));
    colCol.setCellEditor(new ComboBoxCellEditor(column));
    TableColumn colOpr = table.getColumnModel().getColumn(1);
    colOpr.setCellRenderer(new ComboBoxCellRenderer(oprator));
    colOpr.setCellEditor(new ComboBoxCellEditor(oprator));
    TableColumn colLog = table.getColumnModel().getColumn(3);
    colLog.setCellRenderer(new ComboBoxCellRenderer(number));
    colLog.setCellEditor(new ComboBoxCellEditor(number));
    scrollpane = new JScrollPane(table);
    getContentPane().setLayout(new BorderLayout());
    getContentPane().add(scrollpane,BorderLayout.CENTER);
    panelButton = new JPanel();
    btADD = new JButton("ADD");
    btCancel = new JButton("Cancel");
    panelButton.add(btADD);
    panelButton.add(btCancel);
    getContentPane().add(panelButton,BorderLayout.SOUTH);
    btCancel.addActionListener(new ActionListener(){
    public void actionPerformed(ActionEvent e) {
    dispose();
    btADD.addActionListener(new ActionListener(){
    public void actionPerformed(ActionEvent e) {
    model.addRow(data);
    getContentPane().add(scrollpane);
    setSize(500,500);
    class ComboBoxCellRenderer extends JComboBox implements TableCellRenderer {
    public ComboBoxCellRenderer(String[] items) {
    super(items);
    public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
    if (isSelected) {
    //DO NOTHIING
    } else {
    //DO NOTHIING
    // Select the current value
    if(value == null)
    setSelectedIndex(0);
    else
    setSelectedItem(value);
    return this;
    public class ComboBoxCellEditor extends DefaultCellEditor {
    public ComboBoxCellEditor(String[] items) {
    super(new JComboBox(items));
    * @param args the command line arguments
    public static void main(String[] args) {
    MainTable mt = new MainTable();
    mt.setVisible(true);
    }

    Don't forget to use the [url http://forum.java.sun.com/help.jspa?sec=formatting]Code Formatting Tags so the posted code retains its original formatting.
    Don't know why the code works the way it does, but the code is wrong. The correct way to add a row is like this:
    //model.addRow(data);
    String[] rowData = { " ", " ", " ", " "};
    model.addRow(rowData);

  • JComboBox addActionListener problem?

    HI,
    i am using JComboBox to add each item action perform of use StyleEditorKit.FontSizeAction("String", int), but i only can add one item action perform only. See my code any problem...
    for(int i>12;i<=50 ; i++){
                  comboBox.addItem(" "+i);
               // i want to loop each item can function
                comboBox.addActionListener(new StyleEditorKit.FontSizeAcion("i ", i)Thanks

    FontSizeAction is able to set the size to a value delivered in String format as the command String of its ActionEvent. Unfortunately, the JComboBox doesn't deliver the String value of the selected item as command string but an arbitrary value to be set once. So you have to wrap your FontSizeAction in a custom ActionListener of your own where you retrieve the selected item, cast it to a String and pass this value to FontSizeAction as the command String of a new ActionEvent object.
    You should also get rid of that whitespace when creating the size value, String.valueOf(int) is a better way to create a String for an int.

  • JComboBox Dropping Problem

    Hi, I have a JComboBox in a table cell with all the Item I need. But the problem is when I click on JComboBox, dropdown menu pops up and immediately hides automatically. And cannot allow me to choose anything.
    Any suggestions plz.
    Thanks

    You've got a coding problem, so read this section from the Swing tutorial on [url http://java.sun.com/docs/books/tutorial/uiswing/components/combobox.html]How to Use Combo Boxes for example on how to do this correctly.

  • JComboBox MouseListener Problem

    Hi!
    I have problem in getting mouseEntered event from a JComboBox. I have registered a MouseListener with it but it doesn't fire any mouseEvent. Anyone has any idea how to get the mouseEntered Event fired from a JComboBox??
    Thanks!!

    Even I, have a similar problem. My obejective is to display the tooltip, When I move the mouse over every individual item in the combo box. The combo basically has a JList. So, I overrided the getListCellRenderer(...) method. It is not displaying the toolTip when the combo initially has no selectedItem. If there is a selected item, the first time itslef, it displays the toolTip. If theres no selectedItem, it displays the toolTip when I move the mouse out of the combo(when the combo is expanded). Tried all possible combinations... but doesnt work. Have set the toolTip with setToolTipText() method... and when I print the toolTip with getToolTipText() method. It prints correctly, but isnt getting displayed.. :-(

  • JComboBox Editing problem

    hi all ,
    I have problem with JComboBox
    like this :
    JComboBox comTech = new JComboBox();
    comTech.addItem(" ");
    comTech.addItem("one");
    comTech.addItem("two");
    the problem is I want first( comTech.addItem(" ");) item is Editable remaing are uneditable
    I am not getting any solution if anyone knows please send the solution
    thanks

    You missunderstand the use of JComboBox. A JComboBox is used to allow the user to selection from a list of items.
    An uneditable combox allows the user to select an item from the list.
    An editable combo box allows the user to select an item from the list or to enter there own value. It does not allow you to change the value of the entries in the list.
    See this section from the Swing tutorial on "How to Use Combo Boxes":
    http://java.sun.com/docs/books/tutorial/uiswing/components/combobox.html

  • 2 JComboBox  sync problem

    Hi, im getting crazy with this error. I have two different JComboBox with two differents DefaultComboBoxModel.
    The first shows a list of files.
    The second shows a data list from the selected file in the first.
    When i select a different file in the first combo, i want to change the data list in the second combo. So i call the removeAllElements method in the DefaultComboBoxModel, but i dont know why, then the second combo code is executed too (it shouldnt) and i get an error.
    The code is something like this:
    cmb1 is a jcombobox linked to dcbm1, which is a defaultcomboboxmodel
    cmb2 is a jcombobox linked to dcbm2, which is a defaultcomboboxmodel
    MyObject is a customized class which has two fields: a Vector and a String. There is a Vector of MyObject, where is load the file data.
      void cmb1_actionPerformed(ActionEvent e){
        dcbm2.removeAllElements();
        // Load the file
        // Get data load on vector (class Vector)
        // Then, send data from vector to 2nd combomodel:
        for (int i=0; i<vector.size(); i++){
          mo = (MyObject)vector.get(i);
          dcbm2.addElement(mo.getString());
      void cmb2_actionPerformed(ActionEvent e){
        dlm.clear();                                                    // ListModel which i use to show data
        int x = cmb2.getSelectedIndex();
        m = (MyObject)vector.get(x);                       // This line throws the error (ArrayOutOfBounds). x=-1
        vector2 = m.getVector();
        for (int i=0; i<vector2.size(); i++){
          dlm.addElement((vector2.getString()
      }So thats my problem. When i select an item in the 1st combo, the 2nd combo code is executed too, throwing an ArrayIndexOutOfBounds because there is no item selected

    as I see, in this listing, you did not try using what I told you before, try using this:
    public void actionPerformed(ActionEvent e) {
         Object obj = e.getSource();
         if (obj == cmbFiles) {
              parser = new MyXMLParser((String) dcbmFiles.getSelectedItem());
              try {
                   carrera = parser.read();
              } catch (Exception z) {
                   z.printStackTrace();
              cursos = carrera.getCursos();
              for (int i = 0; i < cursos.size(); i++) {
                   cur = (Curso) cursos.get(i);
                   dcbmCursos.addElement(cur.getCurso());
         } else if (obj == cmbCursos) {
              dlmAsignaturas.clear();
              int x = cmbCursos.getSelectedIndex();
              cur = (Curso) cursos.get(x);
              asignaturas = cur.getAsignaturas();
              for (int i = 0; i < asignaturas.size(); i++) {
                   dlmAsignaturas.addElement(
                        ((Asignatura) asignaturas.get(i)).getId()
                             + ((Asignatura) asignaturas.get(i)).getGrupo().toLowerCase());
    }

  • Flex builder 3 debug and autocomplete problems

    I have been working with Adobe Flex Builder for building Flash applications over a year. Recently I tried a few beta SDKs - 3.4 and 4.0. After playing arround with these SDKs and returning to a stable one (3.2) - Flex builder started causing some problems with autocomplete and debugging:
    Autocomplete - when selecting class members from autocomplete - it usually clears all standard library import statements from the class. I started copying and remarking these import statements for retrieving them back after they are deleted.
    Debug - it won't stop on most breakpoints (it used to before changing SDKs). Mostly it ignores my breakpoints.
    I would love to hear any ideas about the cause and possible solution to these problems.
    Tal Yaniv

    I think the problem you are experiencing is this one:
    http://subclipse.tigris.org/issues/show_bug.cgi?id=511
    You probably have Subclipse 1.2.4 installed, which is the
    latest official release. But the new release based on Subversion
    1.5 has been in development for over a year. It will be version
    1.4.0 and probably released next week when Subversion 1.5 is
    released.

  • Nautilus autocompletion problem

    Probably related to the recent upgrade, but I'm not sure. Yesterday seems so long and I've probably lost count of time.
    In addition to this endless spawning problem: http://bbs.archlinux.org/viewtopic.php?id=69219, the location bar autocompletion was also gone. Both problems happen with a new user account, so I doubt if my own configs are in conflict with nautilus.
    Auto complete still works with root nautilus, much the same as described in the Ubuntu forum here: http://ubuntuforums.org/showthread.php?t=980450

    Try changing [global] "security = share" to "security = user" and instead just pre-define allowed users with "valid users = johndoe" (change johndoe to your account ofc). If you still have issues, see basic config example on my wiki here http://wiki.gotux.net/config/samba

  • JComboBox - autocomplete

    Hello everyone!
    I wrote a piece of code that makes a JComboBox work autocomplete. It's working fine but not when I set the look and feel as a system look and feel - not java look and feel. If you're gonna read the code trying to help me, you're gonna see, that if the user types in the combo box some character, the text gets highlited. In the java look and feel it doesn't. So the highliting is only tisturbing the functionality of the combo box.
    Any suggestions?
    Thanks for future help!
    The code:
    import java.awt.event.KeyAdapter;
    import java.awt.event.KeyEvent;
    import java.util.Vector;
    import javax.swing.JComboBox;
    import javax.swing.JFrame;
    import javax.swing.JTextField;
    import javax.swing.UIManager;
    class Testing extends JFrame {
        JComboBox jcb = null;
        Vector<String> v = null;
        public Testing() {
            this.getContentPane().setLayout(null);
            this.setLocation(300, 30);
            this.setSize(300, 300);
            this.setDefaultCloseOperation(EXIT_ON_CLOSE);
            v = new Vector<String>();
            v.add("tlakovanje");
            v.add("tlakovec");
            v.add("tlakovana cesta");
            v.add("tla&#269;an");
            v.add("tlaka");
            v.add("slovenec");
            v.add("slovenka");
            v.add("slovenija");
            v.add("slovar");
            v.add("slovenci");
            v.add("&#269;ajra");
            v.add("&#269;aranje");
            jcb = new JComboBox();
            jcb.setEditable(true);
            jcb.setSelectedItem("");
            for (int i = 0; i < v.size(); i++) {
                jcb.addItem(v.get(i));
            jcb.getEditor().getEditorComponent().addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent e) {
                if (e.getKeyCode() != 38 && e.getKeyCode() != 40 && e.getKeyCode() != 10) {
                    String a = jcb.getEditor().getItem().toString();
                    jcb.removeAllItems();
                    int st = 0;
                    for (int i = 0; i < v.size(); i++) {
                        if (v.get(i).startsWith(a)) { jcb.addItem(v.get(i)); st++; }
                    jcb.getEditor().setItem(new String(a));
                    jcb.hidePopup();
                    if (st != 0) { jcb.showPopup(); }
            jcb.setBounds(20, 20, 150, 20);
            this.getContentPane().add(jcb);
            this.setVisible(true);
        public static void main(String[] args) {
            UIManager.LookAndFeelInfo[] l = UIManager.getInstalledLookAndFeels();
            try {
                UIManager.setLookAndFeel(l[0].getClassName());
            } catch (Exception e) {
                e.printStackTrace();
            Testing testing;
            testing = new Testing();
    }Tilen

    OOhhhh shit .. it really works :) !!! Thanks dude! I was searching and searching for this caret trick but I didn't know how to do it cause the item that's set on the combo box editor actually wasn't a JTextField. It was just an object that I had to cast into an JTextField.
    And sorry ... gonna look the themes next time to post into the right one :).
    Thanks alot dude ;).

  • JTable with JComboBox/JSpinner problem

    The following code has a JTable with 2 columns.The lst column has JComboBoxes, the 2nd column has JSpinners.I want to set the spinner range of values based on the selection of JComboBox. The JComboBox selections are "small" and "large". For "small" the spinner should range from 0..49, for "large" from 50..99. When a selection is made, MyTable.itemStateChanged() is called, which in turn calls SpinnerEditor.setValueRange(). This sets an array with the desired values and then sets the model with this array. However, it sets the range not only for the row in which the combo box was clicked, but all rows.
    So in MyTable.setCellComponents(), there is this:
    spinnerEditor = new SpinnerEditor(this, defaultTableModel);
    modelColumn.setCellEditor(spinnerEditor);
    If the table has n rows, are n SpinnerEditors created, or just 1?
    If 1, do n need to be created and if so, how?
    public class MyTable extends JTable implements ItemListener {
         private DefaultTableModel defaultTableModel;
         private Vector<Object> columnNameVector;
         private JComboBox jComboBox;
         private SpinnerEditor spinnerEditor;
         private final int COMBO_BOX_COLUMN = 0;
         final static int SPINNER_COLUMN = 1;
         public static String SMALL = "Small";
         public String LARGE = "Large";
         private final String[] SMALL_LARGE = {
                   SMALL,
                   LARGE };
         public MyTable(String name, Object[][] variableNameArray, Object[] columnNameArray) {
              columnNameVector = new Vector<Object>();
              // need column names in order to make copy of table model
              for (Object object : columnNameArray) {
                   columnNameVector.add(object);
              defaultTableModel = new DefaultTableModel(variableNameArray, columnNameArray);
              this.setModel(defaultTableModel)     ;
              setCellComponents();
              setListeners();
         private void setCellComponents() {
              // combo box column -----------------------------------------------
              TableColumn modelColumn = this.getColumnModel().getColumn(COMBO_BOX_COLUMN);
              jComboBox = new JComboBox(SMALL_LARGE);
              // set default values
              for (int row = 0; row < defaultTableModel.getRowCount(); row++) {
                   defaultTableModel.setValueAt(SMALL_LARGE[0], row, COMBO_BOX_COLUMN);
              modelColumn.setCellEditor(new DefaultCellEditor(jComboBox));
              DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
              renderer.setToolTipText("Click for small/large"); // tooltip
              modelColumn.setCellRenderer(renderer);
              // index spinner column ------------------------------------------------------------
              modelColumn = this.getColumnModel().getColumn(SPINNER_COLUMN);
              spinnerEditor = new SpinnerEditor(this, defaultTableModel);
              modelColumn.setCellEditor(spinnerEditor);
              renderer = new DefaultTableCellRenderer();
              renderer.setToolTipText("Click for index value"); // tooltip
              modelColumn.setCellRenderer(renderer);
         private void setListeners() {
              jComboBox.addItemListener(this);
         @Override
         public void itemStateChanged(ItemEvent event) {
              // set spinner values depending on small or large
              String smallOrLarge = (String)event.getItem();
              if (this.getEditingRow() != -1 && this.getEditingColumn() != -1) {
                   spinnerEditor.setValueRange(smallOrLarge);
         public static void main(String[] args) {
              try{
                   UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
              catch (Exception e){
                   e.printStackTrace();
              String[] columnNameArray = {"JComboBox", "JSpinner"};
              Object[][]  dataArray = {
                        {"", "0"},
                        {"", "0"},
                        {"", "0"},
              final MyTable myTable = new MyTable("called from main", dataArray, columnNameArray);
              final JFrame frame = new JFrame();
              frame.getContentPane().add(new JScrollPane(myTable));
              frame.setTitle("My Table");
              frame.setPreferredSize(new Dimension(200, 125));
              frame.addWindowListener(new WindowAdapter(){
                   @Override
                   public void windowClosing(WindowEvent e) {
              frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
              frame.setLocation(800, 400);
              frame.pack();
              frame.setVisible(true);
    public class SpinnerEditor extends AbstractCellEditor implements TableCellEditor {
         private JComponent parent;
         private DefaultTableModel defaultTableModel;
         private final JSpinner spinner = new JSpinner();
         private String[] spinValues;
         private int row;
         private int column;
         public SpinnerEditor(JTable parent, DefaultTableModel defaultTableModel ) {
              super();
              this.parent = parent;
              this.defaultTableModel = defaultTableModel;
              setValueRange(MyTable.SMALL);
              // update every time spinner is incremented or decremented
              spinner.addChangeListener(new ChangeListener(){
                   public void stateChanged(ChangeEvent e) {
                        String value = (String) spinner.getValue();
                        System.out.println ("SpinnerEditor.stateChanged(): " + value);
                        setValue(value);
         private void setValue(String value) {
              // save to equation string
              System.out.println ("SpinnerEditor.setValue(): " + value + " at (" + row + ", " + MyTable.SPINNER_COLUMN + ")");
              ((JTable) parent).setValueAt(spinner.getValue(), this.row, this.column);
         @Override
         public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column)      {
              System.out.println ("SpinnerEditor.getTableCellEditorComponent(): row: " + row + "\tcolumn: " + column);
              System.out.println ("SpinnerEditor.getTableCellEditorComponent(): value: " + value);
              this.row = row;
              this.column = column;
              return spinner;
         @Override
         public boolean isCellEditable(EventObject evt) {
              return true;
         // Returns the spinners current value.
         @Override
         public Object getCellEditorValue() {
              return spinner.getValue();
         @Override
         public boolean stopCellEditing() {
              System.out.println("SpinnerEditor.stopCellEditing(): spinner: " + spinner.getValue() + " at (" + this.row + ", " + this.column + ")");
              ((JTable) parent).setValueAt(spinner.getValue(), this.row, this.column);
              return true;
         public void setValueRange(String smallOrLarge) {
              System.out.println ("SpinnerEditor.setValueRange for " + smallOrLarge);
              final int ARRAY_SIZE = 50;
              if (MyTable.SMALL.equals(smallOrLarge)) {
                   final int MIN_SPIN_VALUE = 0;               
                   final int MAX_SPIN_VALUE = 49;
                   //System.out.println ("SpinnerEditor.setValueRange(): [" + MIN_SPIN_VALUE + ".." +  MAX_SPIN_VALUE + "]");
                   spinValues = new String[ARRAY_SIZE];
                   for (int i = MIN_SPIN_VALUE; i <= MAX_SPIN_VALUE; i++) {
                        spinValues[i] = new String(Integer.toString(i));
              else { // large
                   final int MIN_SPIN_VALUE = 50;               
                   final int MAX_SPIN_VALUE = 99;
                   //System.out.println ("SpinnerEditor.setValueRange(): [" + MIN_SPIN_VALUE + ".." +  MAX_SPIN_VALUE + "]");
                   spinValues = new String[ARRAY_SIZE];
                   for (int i = 0; i <ARRAY_SIZE; i++) {
                        spinValues[i] = new String(Integer.toString(MIN_SPIN_VALUE + i));
                   //for (int i = 0; i <ARRAY_SIZE; i++) {
                   //     System.out.println ("spinValues[" + i + "] = " + spinValues);
              System.out.println ("SpinnerEditor.setValueRange(): [" + spinValues[0] + ".." + spinValues[ARRAY_SIZE-1] + "]");
              // set model
              spinner.setModel(new SpinnerListModel(java.util.Arrays.asList(spinValues)));

    However, it sets the range not only for the row in which the combo box was clicked, but all rows. Yes, because a single editor is used by the column.
    One solution is to create two editors, then you override the getCellEditor(...) method to return the appropriated editor. Something like:
    If (column == ?)
        if (smallOrLarge)
          return the small or large spinner editor
        else
           return the large spinner editor
    else
        return super.getCellEditor(...);

  • AJAX AutoComplete problem with arabic

    I'm using Ajax AutoComplete component in my project by creating the String array (String[]) from a table created in database
    The Ajax AutoComplete component work fine with English data but when working with Arabic data it gives me an empty list...!!!!
    does any one know why this is happening with Arabic data?
    this is my code for creating the string array:
    public String[] getNames() {
            RowKey rowKeys[] = namesDP.getAllRows();
            names =  new String[rowKeys.length];
            for (int i = 0; i < rowKeys.length; i++) {
                namesDP.setCursorRow(rowKeys);
    names[i] = namesDP.getValue("NAME").toString();
    return this.names;
    }NAME is the field that holds the English data and for Arabic i just change it to NAME1 which holds the Arabic data                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    Hi There,
    Creator will be EOLed soon, Netbeans is the latest version of Creator. Pls post your question on NB mailing lists at http://www.netbeans.org/community/lists/top.html for better response.
    Thanks
    K

Maybe you are looking for

  • Remote Desktop and Mac Server Access

    Hi Everyone, I'm looking to find out if the iPad can support remote desktop access to another Mac and if Apple has released "Server Admin" and related tools for monitoring and administration of their Mac Server OSX? Regards, Steve

  • Currency on SCD line item

    Dear SAP Experts, We have a vendor that is defined in 2 different company codes (United States and Canada).   Currency for United States is 'USD'.  Currency for Canada is 'CAD'.  As you can see from the Vendor Display transaction (VK03), the purchasi

  • How can I get album artwork without using iTunes on the computer?

    I used touchcopy to copy the songs off my ipod touch onto my new computer, so i could then load them onto my ipod nano. I have got the songs on the nano, and theyre still on my touch, but there is no album artwork on either. For my nano, i can use iT

  • How to run a client in j2ee

    Hi Guys, I have successfully created a bean and deployed it in J2EE server. My next step according to the head first ejb is to create a client. I compiled AdviceClient successfully (Thanks to grava). However when I try to run the compiled class I get

  • How to have KM useful links ivew in a drill down tree format.

    Hi All, I am having a KM iview which displays useful links. The problem is it initially displays only one/two levels of drilldown from the configured root folder. How can we modify such that it displays <b>n</b> levels of folders & links from the con