?
Solved

TreeCellEditor problem

Posted on 2001-07-19
11
Medium Priority
?
273 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 30 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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
The viewer will learn how to implement Singleton Design Pattern in Java.
Suggested Courses
Course of the Month11 days, 16 hours left to enroll

752 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