• Post Reply Bookmark Topic Watch Topic
  • New Topic

display more than one icon into cell

 
ramesh kancherla
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI,
This is Ramesh. I am implementing jtable in my frame. The jtable contains multiple columns. I am inserting icons into that columns.

I have to show more than one icon in each cell.

is there any way to display more than one icon into cell (or)
display each icon into each column and then columns merging into single column

can any one please give me suggestion how do i implement it.

Thanks & Regards
Rameshk
 
Ted Smyth
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Render multiple icons onto a JPanel, and render the JPanel in the cell.
 
ramesh kancherla
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ted Smyth ,
i am handling events on individual cells. if i placed multiple icons into cell I am unable to handling events on individual icon.

can you please give me suggestion how can i handle event on individual icon when i have multiple icons in my cell.

Thanks & Regards
Ramesh K
[ August 28, 2008: Message edited by: ramesh kancherla ]
 
Rob Spoor
Sheriff
Posts: 20819
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do you determine how many and which icons to show? What is stored in the cells?
 
ramesh kancherla
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Rob Prime,

I have to show icons like as

*************************
column1 **** column2 ***

*************************
icon1 icon2 **** icon3 icon4 ***
*************************
icon1 icon2 **** icon3 icon4 ***

*************************

each cell contains two icons and also handling event on each icon.
can you please give me suggestion how can i implement it.

Thanks & Regards
Ramesh K
[ August 28, 2008: Message edited by: ramesh kancherla ]
 
Campbell Ritchie
Marshal
Posts: 52565
119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ted Smyth has already told you how to get two Icons into a cell.

You can't simply add Listeners to Icons, so wrap the Icons in JLabels or even JButtons and add Listeners to them.
If you can add two Icons to a cell, you can use the same technique to add two JButtons or JLabels to the cell.
 
ramesh kancherla
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Campbell Ritchie,

if I added buttons with icons into cell and add actionListener to buttons.I can find button action. But how can I find which row button is selected.
Here I have to know which row and which button is selected.
can you please give me suggestion.

Thanks & Regards
Ramesh K
 
Campbell Ritchie
Marshal
Posts: 52565
119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't know. Do you have some way of objects on cells "knowing" which row they are on? You could add that information to the buttons' Listeners.

Anybody else??
 
Ted Smyth
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
An extension JLabel/JButton to include a row number (or row identifier - probably preferred) would be a simple solution.

I say that identifier (for example a primary key column in a database table) is preferred because the row number may not update correctly (or at all) unless you account for table sorting.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!