Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

TreeCellEditor problem

Posted on 2001-07-19
11
Medium Priority
?
277 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

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 …
In this post we will learn different types of Android Layout and some basics of an Android App.
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Suggested Courses

636 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