Solved

TreeCellEditor problem

Posted on 2001-07-19
11
242 Views
Last Modified: 2008-02-26
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


0
Comment
Question by:sanjay_thakur
11 Comments
 
LVL 1

Expert Comment

by:eattrig
ID: 6300316
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()
0
 
LVL 92

Expert Comment

by:objects
ID: 6300491
> public class AbstractCellEditor implements TableCellEditor,TreeCellEditor

> why can't I extend these Interfaces?

Your not extending the interfaces, your implementing them?
0
 
LVL 4

Author Comment

by:sanjay_thakur
ID: 6300498
Hi,

I have defined all the methods required but

I still cannot compile the program

0
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
LVL 92

Expert Comment

by:objects
ID: 6300517
Can u post the code.
0
 
LVL 4

Author Comment

by:sanjay_thakur
ID: 6303021

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!



0
 
LVL 7

Expert Comment

by:Igor Bazarny
ID: 6303957
Hi,

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

Regards,
Igor Bazarny
0
 
LVL 92

Accepted Solution

by:
objects earned 10 total points
ID: 6304023
Compiles ok here using Sun 1.3, just added following imports:

import javax.swing.tree.*;
import javax.swing.table.*;
import javax.swing.event.*;
import java.util.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

Maybe it's a problem with Borland.
What if you just implement TreeCellEditor does that cause a problem?
0
 
LVL 4

Author Comment

by:sanjay_thakur
ID: 6304041

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
 



0
 
LVL 92

Expert Comment

by:objects
ID: 6304045
What checkboxes?
0
 
LVL 92

Expert Comment

by:objects
ID: 6305488
If it compiles ok from the command line then there's nothing wrong with your code, it's a JBuilder problem.
0
 
LVL 4

Author Comment

by:sanjay_thakur
ID: 6439015
sorry for the delay again
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This video teaches viewers about errors in exception handling.

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question