Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Combobox in JTable

 
Martin Rea
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 12014
220
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic