Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JTable isCellEditable not working

 
Sabine El Rassy
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everyone,

I'm trying to set 3 specific columns editable in my Jtable. Im overriding the method isCellEditable, and the method is returning true for the correct 3 columns But in the interface the columns are not editable. any ideas? here's the code.




here's where I create the model and Jtable :


Thanks for the help
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you may have to post a working demo of the problem.

strip everything unrelated to the problem (listeners etc),
and post something we can compile/run/observe/tinker
 
Darryl Burke
Bartender
Posts: 5126
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can't spot what might be wrong there. To get better help sooner, post a SSCCE (Short, Self Contained, Correct (Compilable), Example) that demonstrates the problem.

edit What Michael said
 
Sabine El Rassy
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried to remove all listeners but nothing changed. Could it be something related to the jscrollpane?

here's a compilable example:

The table model class



the interface class



thanks again
 
Darryl Burke
Bartender
Posts: 5126
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sabine El Rassy wrote:here's a compilable example:

Not with those imports, which include 28 unused imports that only add clutter, it isn't. Everyone doesn't have MigLayout, and I haven't a clue where the two used npt.util classes came from.
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
here's your code, rebuilt so we can run it.
added the line to make the middle column uneditable, others editable

it works fine, so the problem must be with your enums or non-standard imports
(and, no, the JScrollPane won't have anything to do with changing the editing function of a JTable)

 
Sabine El Rassy
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I found where the error is:
When I override the getColumnClass method, if I put the return type EnumPrice.class the cells wont be editable. If I tried with a return type of String.class it works.
Do you have any idea why the return type EnumPrice.class doesnt work?
thanks
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> Do you have any idea why the return
> type EnumPrice.class doesnt work? 

what is EnumPrice.class?
e.g. a label, a textfield, some-other-component?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic