Different Renderer type per row in same column of JTable?

Discussion in 'Java' started by RobE, Aug 11, 2003.

  1. RobE

    RobE Guest

    Hello,

    I want to provide a field value editing capability using a JTable. I
    want to display different renderers on each row of the Value column
    depending on the field type ie if date render date chooser, if
    multiple strings, render combobox etc. Is that possible to do?

    Thanks in advance,
    Rob.
    RobE, Aug 11, 2003
    #1
    1. Advertising

  2. RobE

    Roedy Green Guest

    On 11 Aug 2003 12:06:05 -0700, (RobE) wrote or
    quoted :

    >I want to provide a field value editing capability using a JTable. I
    >want to display different renderers on each row of the Value column
    >depending on the field type ie if date render date chooser, if
    >multiple strings, render combobox etc. Is that possible to do?


    Renderers are installed per column. You need to write a Renderer that
    looks at the row number and invokes the appropriate method.
    --
    Canadian Mind Products, Roedy Green.
    Coaching, problem solving, economical contract programming.
    See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
    Roedy Green, Aug 11, 2003
    #2
    1. Advertising

  3. Hello
    Take a look at http://manning.spindoczine.com/sbe/ chapter 18. Tables
    ore
    try somthing like this:

    public class MyTable extends JTable {
    public TableCellEditor getCellEditor(int aRow, int aColumn) {
    if (......) {
    return new DefaultCellEditor(new JComboBox(....));

    }
    if (......) {
    return DefaultCellEditor(new .....
    }
    if (......) {
    return super.getCellEditor(aRow,aColumn);
    }
    }

    Jörg Marti



    RobE schrieb:
    > Hello,
    >
    > I want to provide a field value editing capability using a JTable. I
    > want to display different renderers on each row of the Value column
    > depending on the field type ie if date render date chooser, if
    > multiple strings, render combobox etc. Is that possible to do?
    >
    > Thanks in advance,
    > Rob.
    =?ISO-8859-1?Q?J=F6rg_Marti?=, Aug 12, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bryan R. Meyer
    Replies:
    4
    Views:
    3,867
    Bryan R. Meyer
    Sep 6, 2004
  2. Branko Kaucic
    Replies:
    4
    Views:
    13,476
    Branko Kaucic
    Sep 13, 2005
  3. Replies:
    2
    Views:
    2,261
  4. Beaned
    Replies:
    0
    Views:
    475
    Beaned
    Aug 25, 2006
  5. frafel
    Replies:
    14
    Views:
    6,621
Loading...

Share This Page