Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

JTable - enable cursor blink at cell with single click

843806Oct 18 2007 — edited Oct 19 2007
Hi there;

I coudn't find any sample on how to achieve the goal
-> JTable - enable cursor blink at cell with single click
Currently, with single click on the cell, I'm able to edit the text / value. However, it will be more understandable for user, when they see the cursor is blinking.

The cursor only blink when i double click / f2 on the selected cell. Pls advise, thanks in advance.

Comments

843806
Possibly for this you could attach a
CellEditorListener
to the cell in question? Then when you give it focus?

Not sure on how to set the cursor though...
camickr
Override the setClickCountsToStart() to 1 of the DefaultCellEditor.
843806
Nice!
843806
hello, i am lost. could you be share some snippet code with me? i can't figure out where to override the code as mentioned. thanks.
camickr
Create a new DefaultCellEditor. Set the click count property. Add the editor to the table as the default editor.
843806
hello, do you mean like this?
DefaultCellEditor dce = new DefaultCellEditor();
dce.setClickCountsToStart() = 1;
JTable jt.add(dce);
843806
No you'd call:
JTable yourTable = new JTable();
DefaultCellEditor dce = new DefaultCellEditor();

dce.setClickCountToStart(1);

yourTable.setCellEditor(dce);
843806
Actually it'd be more something like
TableCellEditor editor = new DefaultCellEditor(yourTextFieldHere);
editor.setClickCountToStart(1);
yourTable.setCellEditor(editor);
Does that help?
843806
Hi yes, thanks and this may help too.

((DefaultCellEditor)table.getDefaultEditor(String.class)).setClickCountToStart(1);
1 - 9
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Nov 16 2007
Added on Oct 18 2007
9 comments
1,435 views