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 JTable isCellEditable not working 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 "JTable isCellEditable not working" Watch "JTable isCellEditable not working" New topic
Author

JTable isCellEditable not working

Sabine El Rassy
Greenhorn

Joined: Jan 23, 2012
Posts: 10
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

Joined: Jun 09, 2003
Posts: 4632
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

Joined: May 03, 2008
Posts: 4523
    
    5

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

luck, db
There are no new questions, but there may be new answers.
Sabine El Rassy
Greenhorn

Joined: Jan 23, 2012
Posts: 10
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

Joined: May 03, 2008
Posts: 4523
    
    5

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

Joined: Jun 09, 2003
Posts: 4632
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

Joined: Jan 23, 2012
Posts: 10
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

Joined: Jun 09, 2003
Posts: 4632
> 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?
 
 
subject: JTable isCellEditable not working
 
Similar Threads
JTable Dynamic - Urgent
JTable
JTable
JCheckBox in JTable
JTable -Adding Column and Fix Columns Problems