Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...I just want to say how much I value your site. I hope the good work keeps up there. It's really helped me..."

Geography

Where in the world do Tek-Tips members come from?

Customize only the first row to JComboBox in JTableHelpful Member! 

rach18 (Programmer)
28 Mar 09 2:25
How can i customize only the first row to JComboBox in jTable? (Only one row in the JTable, not the whole column)

I tried using the following code:
EachRowEditor rEditor = new EachRowEditor(bti.BTIC.comboBox,false,bti.BTIC);
bti.BTIC.jTable.getColumn(0).setCellEditor(rEditor);

Here the whole column(0) was set to comboBox. When executed, when i click on any cell of column(0), the comboBox is displayed. That is, when the user clicks in a cell of the first column, the drop down list of comboBox is appearing. This behaviour is correct.

But I only need the whole row(0) to be set to JComboBox in JTable. So I tried using the following code:
for (int n=1;n<bti.BTIC.columns.length ; n++)
{
       EachRowEditor rowEditor = new EachRowEditor(false,bti.BTIC);
       rowEditor.add(0, new DefaultCellEditor(new JComboBox(bti.comboBox.getModel())));
       bti.BTIC.jTable.getColumn(bti.BTIC.columns[n]).setCellEditor(rowEditor);
}

where JTable and JComboBox are defined/implemented under bti.BTIC.
Here i was able to achieve in setting the whole row(0) to comboBox. When executed, when i clicked on any cell of row(0), immediately, i'm not able to display the comboBox. The user has to click on that cell, type something to get the drop-down list of comboBox, OR double click on that cell to get the drop-down list.

My question is to get the drop-down list of comboBox when the user once clicks on the cell of a JTable row which is customized to JComboBox.

Any help would be appreciated.

  
stefanwagner (Programmer)
28 Mar 09 12:08
I don't know a way to do so.

Maybe it's a better idea to use selfmade, separated row of comboboxes instead of a JTable-row?  

don't visit my homepage: http://home.arcor.de/hirnstrom/minis/index.html

Helpful Member!  timw (Programmer)
2 Apr 09 11:24
You would set a TableCellEditor on the JTable. Sub-class the DefaultCellEditor for this, overriding the getTableCellEditorComponent method. This method supplies a column parameter (among others). If this parameter indicates column zero, return a custom editing component of you choice, otherwise delegate sourcing the component to the superclass.

Tim

timw (Programmer)
2 Apr 09 11:32
... and I meant row, not column smile Return your customised editing component when the ROW parameter is zero.

Tim

rach18 (Programmer)
9 Apr 09 23:44
Thanks Timw! smile
Overriding getTableCellEditorComponent method, helped me in resolving the issue.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Back To Forum

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close