This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes DEFAULTCELLEDITOR without double click action Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "DEFAULTCELLEDITOR without double click action" Watch "DEFAULTCELLEDITOR without double click action" New topic
Author

DEFAULTCELLEDITOR without double click action

alex d�az
Greenhorn

Joined: Oct 22, 2006
Posts: 6
Hi...

By the way, we usually active a cell using double click over the cell to be

edit.

This is my code for instance my own cell editor:

CELL_EDIT = new myTableEditor();
TABLE.setDefaultEditor(Object.class, CELL_EDIT);.

It is working fine, when I double click over a cell, it start to editing

mode.

However I would like to active the cell editing without double click action.

Like to press a button in the program or a code that say:


// I WANT TO SET VALUES FROM A TEXTFIELD OUT OF THE TABLE BUT INSIDE OF THE

PANEL.

ROW = 2; // whatever that I set
COL = 0; // whatever that I set

CELL_EDIT = new myTableEditor();
TABLE.setDefaultEditor(Object.class, CELL_EDIT, ROW, COL);.

Somebody could help me?

Thanks...
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

ALEX CD -

Welcome to JavaRanch. We don't have too many rules around here but we do have a Naming Policy. Please adjust your display name accordingly.

Also note that shouting your name by putting it in all CAPS is considered bad netiquette.


GenRocket - Experts at Building Test Data
Terry Ong
Ranch Hand

Joined: Apr 07, 2006
Posts: 50
Is this what you wanted?

table.editCellAt(2, 2);



Class JTable
link
editCellAt(int row, int column)
Programmatically starts editing the cell at row and column, if the cell is editable.
alex d�az
Greenhorn

Joined: Oct 22, 2006
Posts: 6
Thanks...

Ok, I am using a compare value in a FOR cycle.

I need to check cell by cell from a table and while is checking, this stop looping (like to break the FOR loop) when it got a find a wrong value and then set the cursor inside of the cell that has the wrong value.

This is for make able to user edit the cell.

It is without using double click or whatevet click event.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61448
    
  67

"alexcd", Gregg's request that you change your display name to adhere to JavaRanch standards was not a suggestion. Valid display names are mandatory for participation on the Ranch. Please change your display name as instructed prior to your next post.

Your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Be aware that accounts with invalid display names are removed.

bear
JavaRanch Sheriff


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Terry Ong
Ranch Hand

Joined: Apr 07, 2006
Posts: 50
Originally posted by ALEX CD:

I need to check cell by cell from a table and while is checking, this stop looping (like to break the FOR loop) when it got a find a wrong value and then set the cursor inside of the cell that has the wrong value.

This is for make able to user edit the cell.

It is without using double click or whatevet click event.


Don't really get you meant. table.editCellAt(r,c) is not an (mouse) event, its coded.

Can you do this? or something like it?

alex d�az
Greenhorn

Joined: Oct 22, 2006
Posts: 6
YES, it is the point...

However when I write the code like you describe here, it is not working.

It is not opening or starting the cell to be edit.

MYTABLE.editCellAt(COUNT, 0);
break;

I need to check only the column 0 in my table and row x, if there is a value compare wrong, this start edit mode in the cell x that need to change value.

However using your code like I show you I have been done, is not working. Nothing success.
Terry Ong
Ranch Hand

Joined: Apr 07, 2006
Posts: 50
Could you also try using
table.setEditingColumn(c);
table.setEditingRow(r);

before using
table.editCellAt(r, c);
alex d�az
Greenhorn

Joined: Oct 22, 2006
Posts: 6
Ok:

I have a Jtable model with data table [3][3]

I have a button that has specific row and col with values like this:

private void BUTTON_TESTActionPerformed(java.awt.event.ActionEvent evt) {

// here I set values one row and column in the table
int row = 0;
int col = 0;

// Now I want to start editing for example in the row 0 and column 0
mytable.setEditingColumn(0);
mytable.setEditingRow(0);
mytable.editCellAt(0, 0);
}

Usually we start an editing clicking with a mouse over a specific cell in the table. I want to evoid this. I want to start editing in a cell setting the specific row and col from a button and button method call the code edit cell at row 0 and col 0 and the cell will be start to edit (you will see cursor flashing).

The think is that it is not working setting code like I show above.

Thanks...
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

alexcd,

You've been warned about your display name. Please change it to adhere to our Naming Policy. If you post again before changing it, your account will be closed.

Thanks.
Brian Cole
Author
Ranch Hand

Joined: Sep 20, 2005
Posts: 862
After reading the original post I was going to suggest exploring DefaultCellEditor.setClickCountToStart() but, based on the replies, I'm not sure I understand what you are trying to do.


bitguru blog
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: DEFAULTCELLEDITOR without double click action