File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes must click 2 times after clearSelection() Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Reply Bookmark "must click 2 times after clearSelection()" Watch "must click 2 times after clearSelection()" New topic
Author

must click 2 times after clearSelection()

Mathias Nilsson
Ranch Hand

Joined: Aug 21, 2004
Posts: 367
Hi!

I have a JTable and CustomTableCellRenderer that handles the cells color.

A user should be able to mark the cell as long as the cell isn't occupied. If the cell is occupied reset the selection and the user has to make another selection.

I have managed to do this but the problem is that after the table.clearSelection() method I must click on the cell 2 times to select it. Does anybody have a solution to this problem. Here is some code


[ November 21, 2005: Message edited by: P.W Mathias Nilsson ]

SCJP1.4
Ken Blair
Ranch Hand

Joined: Jul 15, 2003
Posts: 1078
Do you know for a fact that it's not selected after one click or do you assume it's not because it hasn't changed color? When and how does a cell become locked or unlocked?
Mathias Nilsson
Ranch Hand

Joined: Aug 21, 2004
Posts: 367
The cell isn't selected after on click just 2.

I implemented it in another way so it's ok for now. I have another question

If a user selects a locked cell, then all the other cell that is selected should change color. Some kind of collition. If the user selects cells that isn't allowed then the whole selection should be invalid.

// Mathias
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: must click 2 times after clearSelection()
 
Similar Threads
Color in JTable
JTextPane as CellRenderer in JTable
JTable row selection
JTable Trouble
JTable renderer - Change the backColor of 2 specific rows.