• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

display more than one icon into cell

 
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Sheriff
Posts: 22821
132
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Marshal
Posts: 80271
430
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 80271
430
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Note to self: don't get into a fist fight with a cactus. Command this tiny ad to do it:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic