This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Swing / AWT / SWT and the fly likes Having Trouble with JTables setValue and changes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Having Trouble with JTables setValue and changes" Watch "Having Trouble with JTables setValue and changes" New topic
Author

Having Trouble with JTables setValue and changes

R Johnson
Greenhorn

Joined: Jan 05, 2010
Posts: 28

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

tologin.remove((Object)masterindex));

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!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Having Trouble with JTables setValue and changes