Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Having Trouble with JTables setValue and changes  RSS feed

R Johnson
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm working on a project with three JTables(Master/Employees who need to log in in the next 30 minutes/Temporary Employee logged in Table) The first column in all three tables is a boolean clocked in. The master has it's own model and the other two have new instances of a different model. The model for the other two tables use an ArrayList<Integer> to store an index of the Master List to essentially point to and retrieve information. I made a SwitchTables class which points to the of the models of all the tables. I use the same instance of this class and just point to it in all the tables so that when column0 value is changed it will switch from/too Temp Emp logged in table and then from/too Needs to Log in. I haven't worked on the coding for time or anything just trying to get the over all desire to work. It works fine as long as I click slowly in any one table. If quick rapid clicks occur in the master table duplicates occur in the destination table. If quick rapid clicks occur in the other tables the boolean value will change however it will not transfer to the other table. I tried to synchronize the methods getValueAt setValueAt firetablecellupdated methods and even Thread.wait(100) to maybe slow things down. I also created Field variable boolean to attempt to turn on/off isCellEditable method of column 0 while changing value. At first I was trying to prevent from searching the ArrayList for duplicates for fear of slowing the program, but as a last resort before asking for help I decided to try it. It didnt' work made things worse. I realize the remove method of an ArrayList can take an Obj/int and the int would be the place in the arraylist so me using Integers I tried to use the Object Integer still didn't work so I tried to (I don't know if this term is right) polymorph like this


Still didn't work. So then I just changed the ArrayList<Integer> to ArrayList<String> and changed everything to String.valueOf/Integer.parseInt depending on what I needed. Still no luck.
I would provide code but to display even just a TableModel is at least 15 lines of code or more so I was afraid it would be too large and discouraging for any help someone might be able to provide. So to my question:

Is there a way to prevent JTables from double clicking or clicking too fast on boolean checkboxes so that code can execute and finish?
Thanks for any help!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!