TreeTable with comboBox CellEditor

This is the forum for JIDE Common Layer which is open sourced at https://github.com/jidesoft/jide-oss. Please note, JIDE technical support doesn't monitor this forum as often as other forums. Please consider subscribe for technical support for JIDE Common Layer so that you can use customer only forum to get a timely response.

Moderator: JIDE Support

Forum rules
Community driven forum for open source JIDE Common Layer. JIDE technical support doesn't monitor this forum as often as other forums. If you only use JIDE Common Layer, please consider subscribing for technical support for JIDE Common Layer so that you can use customer only forum to get a timely response.

TreeTable with comboBox CellEditor

Postby robertho21 » Thu Sep 15, 2011 8:51 am

I'm trying to set a ComboBox CellEditor in a TreeTable without success, Previously I had the same implementation with a simple JTable and custom cell editors work well, do you have an Example how could I use a comboBox cell editor instead the simple text cell editor. my code is online:

Code: Select all

// setting the combobox to the specific column of the table:

      alertPropertiesTable
            .getColumnModel()
            .getColumn(2)
            .setCellEditor(
                  new AlertComboBoxCellEditor(new JComboBox(
                        numberCriteria)));

// custom cell editor

   private class AlertComboBoxCellEditor extends DefaultCellEditor implements
         TableCellEditor {

      private AlertComboBoxCellEditor(final JComboBox comboBox) {
         super(comboBox);
      }

      @Override
      public Component getTableCellEditorComponent(final JTable table,
            final Object value, final boolean isSelected, final int row,
            final int column) {
         final JComboBox comboBox = (JComboBox) super
               .getTableCellEditorComponent(table, value, isSelected, row,
                     column);
         if (!entryPanel.hasChanges()) {
            entryPanel.setChanged(true);
         }
         comboBox.setBorder(BorderFactory.createLineBorder(Color.black));
         comboBox.setSelectedItem(value);
         return comboBox;
      }
   }



Thanks.
robertho21
 
Posts: 10
Joined: Fri Oct 29, 2010 4:38 pm

Re: TreeTable with comboBox CellEditor

Postby JIDE Support » Thu Sep 15, 2011 11:16 am

Please give JIDE PropertyPaneDemo a try. PropertyTable is a subclass of TreeTable. In that demo, we registered a lot of combo box cell editor. I would recommend you use CellEditorManager to register cell editors for your table, which will help you persist cell editors even if table structure changed event is received. Regarding the combo box cell editor itself, there is a trick that you need put a client property, "JComboBox.isTableCellEditor", to JComboBox to let it know it's being used as a cell editor.

Thanks,
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37219
Joined: Sun Sep 14, 2003 10:49 am


Return to JIDE Common Layer Open Source Project Discussion (Community Driven)

Who is online

Users browsing this forum: Google [Bot] and 14 guests

cron