JTable: toggle an icon when I double-click a cell - swing

I have a table column that I'm overriding the DefaultCellRenderer to display an icon.
Is there a way I could detect double-clicks on a JTable cell, so I can toggle the corresponding row value's state so that it changes the icon between two values (representing "off" and "on")?

There's two ways:
1) The easier way: Attach a mouse listener to the table, listen for a double click, find the row and column by rowAtPoint/columAtPoint, chenge the value, and call fireCellChanged() in the table model.
2) The harder (but slightly better) way: Have a custom cell editor that upon editing, changes the value, and calls stopCellEditing().
You don't need to do both.
Check this out as well, which does similar but with a button:
http://tips4java.wordpress.com/2009/07/12/table-button-column/

When you perform a single click, the cell rendered is replaced by the cell editor, so provide also a cell editor with same appearance than the rendered, add a mouse listener and capture the double-click and perform any desired action. When you finish invoke stopCellEditing().

Related

Remove the editing cursor in the table's fields of Forms in Access

I have some Forms in my project which tables. Those tables has records, where I have on each line, some text fields (informational), and some buttons. When I select one of those lines with the mouse, by clicking on one of the text fields the editing cursor is always twinkeling in the field where I clicked. I would like that my mouse click only select the line in a color, and doesn't edit the field (This cursor is not a real edit, because it's impossible to really modify something to the edited text, but it would be more professionnal to remove it)
Any solution? (VBA/Access Form design,...) Thanks a lot
Put a small (virtually invisible) control on the forms detail line. In each field you don't want them to settle on put a "got_focus" event that resets the focus to the virtually invisible control.
You can also use the on current event to set an unbound empty control to make the whole row change colour as per this explanation https://access-programmers.co.uk/forums/showpost.php?p=1480574&postcount=6 . Ignore the very complex code shown initially in the thread.

Perform double click on html element

I want to perform double click on an html element. I can click once, but can't double. I tried to move mouse on element, but couldn't find coordinates.
...
IE.Document.GetElementById(An & "q8").focus
IE.Document.GetElementById(An & "q8").dblclick ' not working on hmtl
...
I can't add, change etc. html codes. So I can't add or change events, attributes. I need to doubleclick on element directly, maybe mousemove and click or something like that.
Double click action selects a value from a popup list, and set it to a inputbox. Keystrokes not working. Client side changes are not applied. I tried to change input value, but when another element's value changes first one returns to original value.
(vb6 and ie8+)

Programmatically deselecting a row in JTable

I want to programmatically deselect a row in JTable. Basically I have cehckbix in my jtable and my row needs to be selected or highlited when I click on checkbox. CLicking in any other column should not highlight the row.
I tries table.removeRowSelectionInterval(row,row) on clicking in cell other than checkbox it did not work.
I tried ListSelectionModelk.clearSelection() and then adding RowSelectionInterval() for rows as needed, it works but it interfere with some other functionality.
So I can't use this.
As #Nizil commented that you can write your own Cell Renderer or Cell Renderer
You also need to look at How to use Tables and How to use CheckBoxes

How to set the first continuous combobox invisible in Access 2007?

I'm trying to add an OR feature in the Continuous Filter Form and as you can see the first combobox shows up which I don't want it to show. Ideally, it should show only when the user wants the second row search option not in the first row filter. I have only OR in the combobox. Thanks for your help and let me know if you need any clarification!
Continuous form controls are all or nothing. If it's visible, it's visible in all rows, if invisible, it's invisible in all rows. There's nothing you can do about that.
You have four options (in order of complexity):
First Option:
The "On Current" event of the form happens when a user moves from one row to another inside the continuous form. you can add an IF statement to that event that disables the first box if the user has moved to the first row.
Second Option:
Have a fixed amount of filter boxes, and don't let the user pass the limit
Third Option:
Have a fixed amount of filter boxes, but make a "forward" and "back" buttons that will change what data the filter boxes link to, effectively making a 'custom' continuous form
Fourth Option:
Dynamically create the textboxes programatically (not recommended)
Set the default 'Visible' property to 'No' and then Reset it to 'Yes' when a second criteria is selected. This will populate the whole column though, just so you know.

Tab key behavior on HTML Table

I have a HTML Table with 5 rows and 5 columns. Now when the user starts filling in the Data, and wants to navigate from One cell to another, they clicks on tab and the cursor moves horizontally.
Instead of Horizontal, I want to move vertically. Like shown below in Image. This is very tricky as we want to override the basic OS? Browser functionality.
The global attribute tabindex:
The tabindex content attribute allows authors to control whether an element is supposed to be focusable, whether it is supposed to be reachable using sequential focus navigation, and what is to be the relative order of the element for the purposes of sequential focus navigation.
The value must be an integer (you need values greater than 0; see the linked spec for details).
One way to do it is to use javascript onkeypress events to then give the next cell down focus. onkeypress="if(event.keycode == 8) {document.getElementById('NEXT CELL DOWN').focus()"} In this example 8 is the tab keycode. NEXT CELL DOWN could be hard coded for each cell or you could use an algorithm based on the current cell ID to move it to the next cell ID. For instance if tab is pressed on cell 1 the next cell could be cell1++. Does that make sense?