• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

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

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Cross posted
http://forums.sun.com/thread.jspa?threadID=5440909
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Darryl.

Alexander,
Please read http://faq.javaranch.com/java/BeForthrightWhenCrossPostingToOtherSites
 
Alexander Walker
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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"
 
Ranch Hand
Posts: 650
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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 .









 
What are you saying? I thought you said that Santa gave you that. And this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic