Link to home
Start Free TrialLog in
Avatar of sanjay_thakur
sanjay_thakur

asked on

TreeCellEditor problem

Hi,

This is a weird thing

I JBuilder I define a class like

public class AbstractCellEditor implements TableCellEditor,TreeCellEditor
{

//some code
}

I get an error
"AbstractCellEditor.java": Error #: 453 : not an interface at line 22, column 60

(JBuilder version: JBuilder 4 foundation 4.0.1.52.0 ,

I know that TreeCellEditor and TableCellEditor are interfaces

why can't I extend these Interfaces?

Any help


Avatar of eattrig
eattrig
Flag of United States of America image

Did you define all of the methods which are required by CellEditor??
TableCellEditor and TreeCellEditor are subinterfaces of CellEditor and therefore all methods of CellEditor must also be defined if you implement these interfaces.


The methods which are required by CellEditor are:

void addCellEditorListener(CellEditorListener l)
void cancelCellEditing()
Object getCellEditorValue()
boolean isCellEditable(EventObject anEvent)
void removeCellEditorListener(CellEditorListener l)
boolean shouldSelectCell(EventObject anEvent)
boolean stopCellEditing()
Avatar of Mick Barry
> public class AbstractCellEditor implements TableCellEditor,TreeCellEditor

> why can't I extend these Interfaces?

Your not extending the interfaces, your implementing them?
Avatar of sanjay_thakur
sanjay_thakur

ASKER

Hi,

I have defined all the methods required but

I still cannot compile the program

Can u post the code.

Here is the code for my  class
when I compile it in JBuilder
I get the error

"TestCellEditor.java": Error #: 453 : not an interface at line 22, column 60



public class TestCellEditor implements TableCellEditor,TreeCellEditor
{
    protected EventListenerList listenerList =new  
                           EventListenerList();
    protected Object value;
    protected ChangeEvent changeEvent = null;
    protected int clickCountToStart = 1;

   
     public Object getCellEditorValue() {
          return value;
     }
     public void setCellEditorValue(Object value) {
          this.value = value;
     }
    public void setClickCountToStart(int count) {
          clickCountToStart = count;
    }
    public int getClickCountToStart() {
          return clickCountToStart;
    }

    public boolean isCellEditable(EventObject anEvent) {
          if (anEvent instanceof MouseEvent) {
          if (((MouseEvent)anEvent).getClickCount() <
                                                            clickCountToStart)
               return false;
          }
          return true;
    }


    public boolean shouldSelectCell(EventObject anEvent) {
          if (this.isCellEditable(anEvent)) {
          if (anEvent == null ||
                    ((MouseEvent)anEvent).getClickCount() >=
                                                            clickCountToStart)
                    return true;
          }
          return false;
     }
    public boolean stopCellEditing() {
          fireEditingStopped();
          return true;
    }
    public void cancelCellEditing() {
          fireEditingCanceled();
    }
    public void addCellEditorListener(CellEditorListener l) {
          listenerList.add(CellEditorListener.class, l);
    }
    public void removeCellEditorListener(CellEditorListener l) {
          listenerList.remove(CellEditorListener.class, l);
    }
    public Component getTreeCellEditorComponent(
                                             JTree tree, Object value,
                              boolean isSelected,
                              boolean expanded,
                              boolean leaf, int row) {
          return null;
    }
    public Component getTableCellEditorComponent(
                                             JTable table, Object value,
                               boolean isSelected,
                               int row, int column) {
          return null;
    }
    protected void fireEditingStopped() {
          Object[] listeners = listenerList.getListenerList();

          for (int i = listeners.length-2; i>=0; i-=2) {
              if (listeners[i]==CellEditorListener.class) {
                    if (changeEvent == null)
                    changeEvent = new ChangeEvent(this);

                    ((CellEditorListener)
                         listeners[i+1]).editingStopped(changeEvent);
          }
          }
    }
    protected void fireEditingCanceled() {
          Object[] listeners = listenerList.getListenerList();

          for (int i = listeners.length-2; i>=0; i-=2) {
              if (listeners[i]==CellEditorListener.class) {
                    if (changeEvent == null)
                    changeEvent = new ChangeEvent(this);

               ((CellEditorListener)
                         listeners[i+1]).editingCanceled(changeEvent);
              }
          }
    }
}


Any help?
p.s :If I declare the class as
public class TestCellEditor implements TableCellEditor

Things are fine.

only TreeCellEditor seems to have a problem!



Hi,

Are you sure you import TreeCellEditor? I cannot imagine what other problem you might have.

Regards,
Igor Bazarny
ASKER CERTIFIED SOLUTION
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial

Yes

If I just Implement TreeCellEditor it gives the same error

"AbstractCellEditor.java": Error #: 453 : not an interface at line 22, column 44

I compiled it at the command prompt
It seems to be ok.

But in JBuilder I cannot!

I am still not able to edit the check boxes

Any help
some source code will be really helpful

thanks
 



What checkboxes?
If it compiles ok from the command line then there's nothing wrong with your code, it's a JBuilder problem.
sorry for the delay again