Hi phil,
In the site i mentioned their are EachRowEditor and EachRowRenderer
classes you could use that
You need to create a renderer and editor and for combobox and checkbox
Then you need to use method setEditorAt and use rowRenderValues.add the
renderers
Finally set the editor and render to the particular column in JTable using
setCellEditor setCellRenderer
Editors and Renders for Combo and Checkbox is as given below
private EachRowEditor rowEditorValues = null;
private EachRowRenderer rowRenderValues = null;
rowEditorValues = new EachRowEditor(your table);
rowRenderValues = new EachRowRenderer();
rowEditorValues.setEditorAt(corres row, new
DefaultCellEditor(comboBox));
rowRenderValues.add(corres row,new ComboBoxRender(retArr));
your table.getColumn(Column Name).setCellEditor(rowEditorValues);
your table.getColumn(Column Name).setCellRenderer(rowRenderValues);
public class ComboBoxEditor extends DefaultCellEditor {
public ComboBoxEditor(String[] items) {
super(new JComboBox(items));
}
}
public class CheckBoxEditor extends JCheckBox {
public CheckBoxEditor() {
setHorizontalAlignment(JLabel.CENTER);
}
}
public class ComboBoxRender extends JComboBox implements TableCellRenderer {
public ComboBoxRender(String[] items) {
super(items);
}
public Component getTableCellRendererComponent(JTable table,Object value,
boolean isSelected, boolean hasFocus, int row, int column) {
setSelectedItem( (value ==null) ? "" : value.toString() );
return this;
}
}
public class CheckBoxRender extends JCheckBox implements TableCellRenderer {
public CheckBoxRender() {
setHorizontalAlignment(JLabel.CENTER);
}
public Component getTableCellRendererComponent(JTable table,Object value,
boolean isSelected, boolean hasFocus, int row, int column) {
if (isSelected) {
setForeground(table.getSelectionForeground());
//super.setBackground(table.getSelectionBackground());
setBackground(table.getSelectionBackground());
} else {
setForeground(table.getForeground());
setBackground(table.getBackground());
}
setSelected((value != null && ((Boolean)value).booleanValue()));
return this;
}
}
----- Original Message -----
From: "philp9" <[EMAIL PROTECTED]>
To: "Renju Philip" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Friday, March 28, 2003 3:56 AM
Subject: RE: Advanced-swing digest, Vol 1 #503 - 3 msgs
> Hi Renju,
>
> Do you mean using the Multi-Component examples, but implementing across a
> row instead? I'll give it a go....
>
> Phil.
>
> -----Original Message-----
> From: philp9 [mailto:[EMAIL PROTECTED]
> Sent: Friday, 28 March 2003 9:11 AM
> To: Renju Philip; [EMAIL PROTECTED]
> Cc: [EMAIL PROTECTED]
> Subject: RE: Advanced-swing digest, Vol 1 #503 - 3 msgs
>
>
> Hi Renju,
>
> I saw those examples, but what I'm after is how to create a row of cells
> across a whole table. Each row cell having a checkbox or a combobox. All
the
> examples I've seen seem to use defaultcelleditors down a column. I need to
> get it to work across a whole row, not just in a single cell or column.
>
> Regards,
> Phil.
>
> -----Original Message-----
> From: Renju Philip [mailto:[EMAIL PROTECTED]
> Sent: Thursday, 27 March 2003 22:59 PM
> To: [EMAIL PROTECTED]
> Cc: [EMAIL PROTECTED]
> Subject: Re: Advanced-swing digest, Vol 1 #503 - 3 msgs
>
>
>
> philip,
> how to define a ROW of checkboxes/comboboxes using defaultcelleditors in a
> JTable
>
> http://www2.gol.com/users/tame/swing/examples/JTableExamples2.html
>
> pls see the following examples
>
> Thanks and regards
> renju
>
_______________________________________________
Advanced-swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/advanced-swing