custom jtable copy command?  
Author Message
tiewknvc9





PostPosted: 2005-11-28 23:28:00 Top

java-programmer, custom jtable copy command? 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!

 
oulan bator





PostPosted: 2005-11-28 23:53:00 Top

java-programmer >> custom jtable copy command? 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

 
zero





PostPosted: 2005-11-28 23:58:00 Top

java-programmer >> custom jtable copy command? "tiewknvc9" <email***@***.com> wrote in news:1133191665.983414.267130
@g47g2000cwa.googlegroups.com:

> 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.

--
Beware the False Authority Syndrome