This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Combobox in JTable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Combobox in JTable" Watch "Combobox in JTable" New topic

Combobox in JTable

Martin Rea

Joined: May 04, 2004
Posts: 12
Hi ranch members,
This is the first mail from me, but I have been following you for a while. I am workin on Bodgitt & Scarper assignment and I am almost done with the programming part. Just as you know it - the forum has been a fantastic place to get inspiration and help.
Now to my question:
I am doing all my configuration in a JTable - (property,value)-pairs - and one of my configuration parameters are what log-level to use (I use Java standard logger and only FINE, WARNING and ERROR). My problem is that I would like this choice to be a non-editable JComboBox residing inside a JTable. I have come so far that I have written my own cell editor:
public class LogCellEditor extends DefaultCellEditor
and I use this from inside my table model:

But when I do this it apparently overrides my isCellEditable(int r, int c) method in my TableModel. In this way I can only choose to have all cells in a column using JComboBox (which was not the intention) or to have only the cell using my JComboBox editable - also not the intention.
Before dropping the idea as a whole I though I would ask all of you - anybody has a good idea?
[Andrew: put the source code between [code] and [/code] UBB tags]
[ May 04, 2004: Message edited by: Andrew Monkhouse ]
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11778

Hi Martin,
Welcome to JavaRanch and this forum.
I have edited your post to put the code between [code] and [/code] UBB tags. Doing this ensures that indenting is preserved, which makes the code easier to read.
When you are writing your post, there are a number of buttons just below the edit pane, which will insert the tags for you, so you don't have to remember what they are.
If you would like to edit your original post so that you can see what I have done, you can click on the button that is just above your post.
Sorry I don't have time right now to think of what a possible answer might be - hopefully someone else here will give you some ideas shortly.
Regards, Andrew

The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
I agree. Here's the link:
subject: Combobox in JTable
It's not a secret anymore!