Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

DEFAULTCELLEDITOR without double click action

 
alex d�az
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Terry Ong
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64830
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"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
 
Terry Ong
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could you also try using
table.setEditingColumn(c);
table.setEditingRow(r);

before using
table.editCellAt(r, c);
 
alex d�az
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 906
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic