I have a JTable with two columns and multiple rows.I want to add ComboBox for some columns(Not for every column).If i am using
its updating combobox for every column.Can any one help me please.
First, JTable is really designed as one piece of a framework, not as a ready to use component. It has several classes that provide pieces of functionality, all of which have default implementations. But the design really is intended for the developer to build each of the component classes according to their needs. If you intend to do serious Swing development, take the time to build up the various components from their interfaces, starting with TableModel.
As far as what displays each cell, look at the TableCellRenderer and TableCellEditor interfaces. Note that one class can implement both interfaces; you don't need separate classes. Also, note that just ONE instance of each interface is instantiated for the table. The table uses the ONE instance over and over, especially TableCellRenderer. Read the API carefully for things like repaint() and revalidate() that need to be stubbed out.
If you use one class for both the rendered and the editor, which makes things easier, remember you need one instance for the renderer and one for the editor.
You control what Component is returned to paint each cell. In the renderer, you should return the same small group of instances (one for each thing you want to display) over and over. Don't instantiate new instances on every call! TableCellRenderer is called hundreds of times a second when the mouse is moving over the table.
As far as the editor, it is only used to paint the one cell that is currently being edited. It is especially important to not keep instantiating whatever Component you return from the editor, since that will cause the values the user types in to go away! stopEditing() is your opportunity to save the value (or to return false, to force editing to continue). cancelEdiing() should throw the new value away.
A final note. The default renderer (not the editor) is a subclass of JLabel. The renderer, and the editor as well, if it is implemented correctly, can actually return *themselves* as the Component. I say this only to point out that you *don't* have to do that. Extend Object, instantiate whatever components (JLabel, JComboBox, etc.) you want to return, and keep them in instance fields. All the renderer or editor has to do is set the value.
I mentioned implementing both interfaces in one class. What I have done is to call the renderer's method from the editor's to set up the component; I then do additional setup needed for editing. I have a very complicated requirement that made me use JPanel as the return Component; I add other components to the JPanel as required. It causes a lot of problems, so I suggest avoiding that solution if you can. (I'm a contractor, and I was given a design and not asked for my input.)
I you're overwhelmed , welcome to Swing. It's not a toy, but it provides you low-level access to almost everything, so you can do almost anything. Take the time to dig into JTable, it's a very common component, and if you understand it, you will understand the others as well.