custom jtable copy command?

T

tiewknvc9

Hi.

I am trying to implement a custom behavior on the copy command on
jtable.

Basically I force the entire row to be selected when a user is working
with myJtable. I feel this is a good design because it allows the user
to quickly see what they are working with, without a doubt.

However I would like to customize the copy command on the jtable
because some of the items in the row are images, which I would not like
to allow the user to copy (it gets converted into text, and it looks
ugly!).

What I would like to do is have the copy command ignore the columns
with the images in them, and only copy the textual columns. Im not
sure how to go about doing this, does anyone have any insight for me?

Thanks!
 
O

oulan bator

Hi,

jtable store its actions in "ActionMap", copy is called "copy" (I
think so, you can check it easily in a debugguer), then :
1- write your own action

Action a = " your action"
jtable.getActionMap().put("copy",a);


and that's all ...


BR
 
Z

zero

Hi.

I am trying to implement a custom behavior on the copy command on
jtable.

Basically I force the entire row to be selected when a user is working
with myJtable. I feel this is a good design because it allows the user
to quickly see what they are working with, without a doubt.

However I would like to customize the copy command on the jtable
because some of the items in the row are images, which I would not like
to allow the user to copy (it gets converted into text, and it looks
ugly!).

What I would like to do is have the copy command ignore the columns
with the images in them, and only copy the textual columns. Im not
sure how to go about doing this, does anyone have any insight for me?

Thanks!

How about something like this

for(int i = 0; i < numColumns; i++)
{
Class colClass = table.getColumnClass(i);
if(colClass.getName().contains("Image")
continue;
// else
// copy the data
}

There may be a better way to code this, but the basic idea is just to get
the type of each column, and then act accordingly.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top