1

I use jPanel as my cell and the table has just one column. It looks like this ( JTable: Buttons in Custom Panel in Cell ).

By default, the panel associated with the row (celll) contains a date when it was created. i want to implement an ActionListere method that will extend( slide down) the jpanel in which the action occured to see the whole jPanel data.

Hope you get what i mean.

Community
  • 1
  • 1
user1306777
  • 459
  • 1
  • 7
  • 13
  • Btw creating a table with just one column defies the principle of having a table. – Jakub Zaverka May 02 '12 at 23:11
  • 1
    @Jakub: I disagree. He'd be creating an intelligent JList, one with a cell editor, and there's nothing wrong with that. – Hovercraft Full Of Eels May 02 '12 at 23:16
  • I have found the solution that should work - SetRowHeigth(int , int); – user1306777 May 02 '12 at 23:25
  • What I cannot understand about this question, is why not simply use a `JList` for it? – Andrew Thompson May 02 '12 at 23:27
  • @Andrew Thompson : Do you mean that i should rather use a JList insead of JTable and displaying all the JPanels? I thought jtable is much more flexible and looks nice. Should i change that? – user1306777 May 02 '12 at 23:35
  • Well the thing is, if it is as shown in the.. I might have misunderstood the requirement. Can you provide ASCII art (or an image) of how two of those items would appear, if one is ..clicked on, whatever causes the action event? For Title0 & Title1 would be good. – Andrew Thompson May 02 '12 at 23:45
  • Basiclly, thats not my picture, but it looks that way. It is going to be like skype friend list, when on mouse down event occurs, one single row changes its background color and so on. The only thing it will differ is that, when you press one single item (mousePressed event) from the table, it wont create a new windows with all the info about the user. all the info will be displayed on the panel where the mousePressed even accoured.Therefore the panel after that action should be a little bit bigger in order to fit all the infos that are going to be displayed.Should I keep going using jtable? – user1306777 May 03 '12 at 00:02
  • As it looks like, skype uses Table as its Friend list. – user1306777 May 03 '12 at 00:05
  • Also consider [`TablePopupEditor`](http://stackoverflow.com/a/3591230/230513) or similar. – trashgod May 03 '12 at 06:04
  • Andrew, the reason for using a JTable in this manner is because the JList doesn't provide editable rows out of the box. This is valid approach to the problem. Personally, I would have gone for a VerticalLayout (from SwingX) in JPanel, but each there own – MadProgrammer Jul 11 '12 at 01:43

1 Answers1

0

Basically, you want to do the same thing that JList.ensureIndexIsVisible(int) but with a table.

Component has a method called "scrollRectToVisible(Rectangle aRect)" which should just about do what you need.

So, using your JTable, you can get the cellRect(int width, int height, boolean includingSpacing) and pass it off to the "scrollRectToVisible"

You're going to have to do some clever work to find out the row of the action, but I assume that you are using a table cell editor which has already provided you with this information

MadProgrammer
  • 343,457
  • 22
  • 230
  • 366