Solved

TreeCellEditor problem

Posted on 2001-07-19
11
220 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
Comment Utility
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
Comment Utility
> 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
Comment Utility
Hi,

I have defined all the methods required but

I still cannot compile the program

0
 
LVL 92

Expert Comment

by:objects
Comment Utility
Can u post the code.
0
 
LVL 4

Author Comment

by:sanjay_thakur
Comment Utility

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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 7

Expert Comment

by:Igor Bazarny
Comment Utility
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
Comment Utility
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
Comment Utility

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
Comment Utility
What checkboxes?
0
 
LVL 92

Expert Comment

by:objects
Comment Utility
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
Comment Utility
sorry for the delay again
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
count7 challenge 12 66
IT Company 5 68
topping3 challenge 14 48
Java Message handling in Service Layer 3 37
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

772 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now