• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Jcomponent in JTable cells

 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am not very familiar with swing. I am trying to use some JComponent in a table. The problem is, though I see the JComponents in the cells, they dont receive any event. I set a custom TableCellRenderer for JComponent type. Here is the code,
table.setDefaultRenderer(javax.swing.JComponent.class,
new TableCellRenderer() {
public Component getTableCellRendererComponent(JTable table,
Object value, boolean isSelected, boolean hasFocus,
int row, int column) {
return (JComponent) table.getValueAt(row, column);
}
});
setMiddleComponent(table);
}
Also, I have those JComponents in the table model, is this design ok for mvc?
I will be very glad if you have the answer, or you can point me to any resource that duscusses this issue.
Thanks.
 
Ranch Hand
Posts: 2823
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Could you explain what you are trying to do? Renderers and events don't have anything to do with each other. The renderer is for display editors are for what happens in JTables. JComponent doesn't really narrow down what you are trying to accomplish.
Here is a link to a site that puts various JComponents in JTables.
 
I'm just a poor boy, I need no sympathy, because I'm easy come, easy go, little high, little low, little ad
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic