aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes JTable with custom checkbox cell editor - problem with the table MouseListener Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JTable with custom checkbox cell editor - problem with the table MouseListener" Watch "JTable with custom checkbox cell editor - problem with the table MouseListener" New topic
Author

JTable with custom checkbox cell editor - problem with the table MouseListener

Alexander Walker
Ranch Hand

Joined: Jun 04, 2010
Posts: 34
I have a Table in which you are only supposed to be able to change the state of the checkbox if you click on the checkbox, and not if you click outside of it (note: the code right now assume that the checkbox is completely aligned to the lift, which it is not, but that has got nothing to do with the problem). However it does still change the state, even if you click outsite of it.

If you click only on the checkbox, the muoseevent will run, however if you click ones outside it, and click ones more on the same cell (doesn't matter if you click inside or oteside the checkbox), the MouseEvent will not run until you change the cell.

And if you click on one checkbox, change to the next checkbox, and then change back to the previous one (meaning you only click ones on the sames checkbox), it seems that, for example if the checkbox is"true", it will first change to" false" and then back to "true" again, and the opposite works too, every time you change the check box you click on. Which results in that you will have to click twice on the checkbox, when you change to it, after having clicked on another checkbox (or cell on another row)

The mouse clicked method, for some reason never seems to run too. That method have to be called manually from the other event methods if it are ro be run.


This code can compile and run, and it shows the problems I have. I don't think I could skip any of it.
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4523
    
    5

Cross posted
http://forums.sun.com/thread.jspa?threadID=5440909


luck, db
There are no new questions, but there may be new answers.
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 9990
    
    7

Thanks Darryl.

Alexander,
Please read http://faq.javaranch.com/java/BeForthrightWhenCrossPostingToOtherSites


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Alexander Walker
Ranch Hand

Joined: Jun 04, 2010
Posts: 34
Maneesh Godbole wrote:Thanks Darryl.

Alexander,
Please read http://faq.javaranch.com/java/BeForthrightWhenCrossPostingToOtherSites


I am very sorry for this. I did'nt even think about it. I didn't mean to annoy anyone, and if I did I, then I am very sorry. But thanks fot notifying me that I should do that, then I now for the next time what I shouldd do.
Alexander Walker
Ranch Hand

Joined: Jun 04, 2010
Posts: 34
I pretty much solved the above problem (I think), after googling and finding out a way to solve it.
I did:

However, I then came upon a new problem, since no celleditor will be in edit mode, It will be difficult to recower the celleditor of the cell you wan't to edit in here

Is there any easy way to do this? Or any way at all?

It would have been nice if there were some kind of invoke method for the celleditor, so that you can invoke a cells editor programatically regardless of whether the table is editable or not.
Alexander Walker
Ranch Hand

Joined: Jun 04, 2010
Posts: 34
I was somehow able to solve the problems myself.

Should I mark the thread as "solved"? Or should you only do that if someone helped you to solve the problem?

Edit: I mean to mark as "Resolved"
Mark E Hansen
Ranch Hand

Joined: Apr 01, 2009
Posts: 642
As the topic starter, you can mark the topic resolved at any time.
For the benefit of other that may have the same problem, you may want to share your solution.
Alexander Walker
Ranch Hand

Joined: Jun 04, 2010
Posts: 34
Mark E Hansen wrote:As the topic starter, you can mark the topic resolved at any time.
For the benefit of other that may have the same problem, you may want to share your solution.


Okey then I will mark this thread as resolved.

I will also share my solution with those who want it. I put them in seperate files, but they should also work if you put them as nestled classes in the class Graphics (or some other class).

I'm sorry if there is too much code, but since classes are depending on each other, it won't work otherewise. It might have been good if there was some kind of hide function for the code, to hide it .









 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JTable with custom checkbox cell editor - problem with the table MouseListener
 
Similar Threads
jtable: column header click
Problem in JTable row selection
checkbox Table problem
Select All checkbox in Jtable
Check Box in JTable header