This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes small swings problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "small swings problem" Watch "small swings problem" New topic

small swings problem

Rashmi Hegde

Joined: Jan 08, 2003
Posts: 9
Hi everybody,

I have a JTable for which i have rendered one column as a JCombobox.
The Combobox appears to be fine.
The problem is when i select a value from the combobox, all the other values of the combobox also get selected the same value .
This happens for the first time only.
For eg i have 1,2,3,4 as combobox elements .
If i select value 1 on the first row all the other row values are also set to one.

Below is some part of the code for clarity.

Please help me.
Thanks in advance.

//this is how i add the jcombobox to the jtable cell.
jtable2.getColumn("VALIDITY").setCellRenderer(new MyComboRenderer(new JComboBox(new String[]{"1","2","3"})));

jtable2.getColumn("VALIDITY").setCellEditor(new MyComboEditor(new JComboBox(new String[]{"1","2","3"})));

Below is the MyComboRenderer and My ComboEditor class

class MyComboRenderer extends CustomTableCellRenderer{

public MyComboRenderer(JComboBox aRenderingComponent) {

public void setValue(Object aValue) {
public void setValue(Object aValue, int row) {
//System.out.println(" -----------cell REndere--------------");

class MyComboEditor extends CustomTableCellEditor implements ActionListener {

public MyComboEditor(JComboBox aRenderingComponent){

/* (non-Javadoc)
* @see
public void setValue(Object aValue) {
// System.out.println(" -----------cell EDITOR-- avalue--------");

public void setValue(Object aValue , int row) {
System.out.println(" -----------cell EDITOR----avalue, , row---------");

public Object getCellEditorValue() {
//System.out.println(" cell editor value");

System.out.println(" Any combo value it prints------- > " + ((JComboBox)this.getEditorComponent()).getSelectedItem());
return ((JComboBox)this.getEditorComponent()).getSelectedItem();


/* (non-Javadoc)
* @see
public void actionPerformed(ActionEvent e) {
// System.out.println(" Action performed ---------------Source is "+e.getSource());
I agree. Here's the link:
subject: small swings problem
Similar Threads
jtable problem please help
Update an Existing combobox in JTable
JTable Columns
MultiComponent JTable
combobox rendered in a Jtable