JTable Selection

Hi, I'm trying to write a simple hex editor program and I figured the best way to display the data would be using a JTable. The issue that I have comes when I try to select some range of data. As of now, I have it so that if you clicked on cell (2,2) and dragged down to cell (4,4) the selected result is a rectangle with the corners at (2,2), (2,4), (4,2) and (4,4). Instead I would like it so that it more like a text editor. So if you were to click in the middle of line 5 and drag down three lines, you'd select everything to the right of the starting position on line 5, all of lines 6 and 7 and everything to the left of the ending position on line 8.

My question is: is there some selection model that will assist me in this, or am I going to have to manually write something to facilitate this?

I apologize if this issue has been addressed in the past, but I was unable to find anything when I searched. If you could, please post a link to where it has be discussed previously.

Thanks,

Deepak

[1034 byte] By [pak22884a] at [2007-10-2 20:22:36]
# 1

A table's selection is maintained by two models: the row selection model and the column selection model. The selected cells are the intersection of these two. Therefore I don't think it is possible (without some serious customisation!) to achieve what you want with a JTable.

I'd say that if you're trying to create a text editor (albeit text that's hex) then a text component is probably the way to be going about it.

Hope this helps.

KPSeala at 2007-7-13 23:05:16 > top of Java-index,Desktop,Core GUI APIs...
# 2

I was afraid of that.

The reason I don't want to use a text component is because I'd like the bytes to have a space between them and for them to be selectable with a single click. Also, I'd like there to be a header over each column to show the offset. At this point it seems like it would be better to write a custom selection model than trying to format a text area to suit my needs.

I will start experimenting with ways to write the selection model(s), but if anyone has any tips, I'd appreciate them.

pak22884a at 2007-7-13 23:05:16 > top of Java-index,Desktop,Core GUI APIs...