Trouble implementing interface

I'm writing a StudentInfo class that implements the Student interface. one common thing about these errors is that each of the methods i have in StudentInfo class cannot implement corresponding method in the Student interface. can someone explain that error for me and show me how to use the List class in my case. Thanks a lot!
This is the Student interface
* A simple interface to allow access to student
* properties from a class data file.
public interface Student {
    // Read-only properties
    List<Double> getGrades();
    String getFirstName();
    String getMiddleInitial();
    String getLastName();
}This is the StudentInfo class i am wrting:
import java.util.List;
/**StudentInfo.java modeling a student's infomation
*A student's info includes first name, middle initial, last name and grades
public class StudentInfo implements Student {
    protected String myFirstName, myMiddleInitial, myLastName;
    protected List<Double> myGrades = new List<Double>();
    StudentInfo(String firstName, String middleInitial, String lastName) {
        myFirstName = firstName;
        myMiddleInitial = middleInitial;
        myLastName = lastName;
    // Read-only properties
    List<Double> getGrades() { return myGrades; }
    String getFirstName() { return myFirstName; }
    String getMiddleInitial() { return myMiddleInitial; }
    String getLastName() { return myLastName; }
}Here are the errors:
StudentInfo.java:19: getLastName() in StudentInfo cannot implement getLastName() in Student; attempting to assign weaker access privileges; was public
String getLastName() { return myLastName; }
^
StudentInfo.java:18: getMiddleInitial() in StudentInfo cannot implement getMiddleInitial() in Student; attempting to assign weaker access privileges; was public
String getMiddleInitial() { return myMiddleInitial; }
^
StudentInfo.java:17: getFirstName() in StudentInfo cannot implement getFirstName() in Student; attempting to assign weaker access privileges; was public
String getFirstName() { return myFirstName; }
^
StudentInfo.java:16: getGrades() in StudentInfo cannot implement getGrades() in Student; attempting to assign weaker access privileges; was public
List<Double> getGrades() { return myGrades; }
^
StudentInfo.java:9: java.util.List is abstract; cannot be instantiated
protected List<Double> myGrades = new List<Double>();

All interface methods are implicitly public, so they have to be public in the class that implements the interface. However, in classes, if you don't specify an explicit access level then it's package-private.
In your implementation class, make the interface methods public.

Similar Messages

  • Public class implements interface

    I am taking my first crack at interfaces: I have superclass A which is a parent of class B, which implements interface C. I need to use class B to make 3 variable instances within class A. I think I will use interface C to make calculations based on the 3 variables. Where do you recommend that I declare and set values for the 3 variables if I need to output the values at the top, in superclass A?
    I'm just a little unclear on pulling these objcts together... thanks in advance.

    I am taking my first crack at interfaces: I have
    superclass A which is a parent of class B, which
    implements interface C. I need to use class B to make
    3 variable instances within class A. I think I will
    use interface C to make calculations based on the 3
    variables. Where do you recommend that I declare and
    set values for the 3 variables if I need to output the
    values at the top, in superclass A?
    I'm just a little unclear on pulling these objcts
    together... thanks in advance. If your variables are going to be used by your superclass A then they had better be declared there. You can work with them whereever you want.
    I'm not sure what you are saying about "...use interface C to make calculations based on the 3 variables." You can't do calculations inside an interface. Furthermore, if B extends A and implements C then A and C are going to be completely separate entities. Any reference to C, even if it is actually an object of type B, will not be able to use anything in A--unless you cast it to B, in which case there is no use in making an interface at all.
    I probably just confused you, but oh well...
    Jeff

  • I am having trouble Trouble implementing one-way SSL on WebLogic 9.2...

    I am having trouble Trouble implementing one-way SSL on WebLogic 9.2. I am using Demo Identity and Demo Trust certificates with a SSL Listen Port Enabled on 7002, and a Two Way Client Cert Behavior of Client Certs Not Requested. I assume that by using Client Certs Not Requested that there is no need to install certificates on user's computers.
    When weblogic is restarted, I get the following log telling me it works...
    <Sep 11, 2012 9:35:16 AM PDT> <Notice> <Security> <BEA-090171> <Loading the identity certificate and private key stored under the alias DemoIdentity from the jks keystore file E:\bea\WEBLOG~1\server\lib\DemoIdentity.jks.>
    <Sep 11, 2012 9:35:17 AM PDT> <Notice> <Security> <BEA-090169> <Loading trusted certificates from the jks keystore file E:\bea\WEBLOG~1\server\lib\DemoTrust.jks.>
    <Sep 11, 2012 9:35:17 AM PDT> <Notice> <Security> <BEA-090169> <Loading trusted certificates from the jks keystore file e:\bea\jdk150_12\jre\lib\security\cacerts.>
    <Sep 11, 2012 9:35:17 AM PDT> <Notice> <Server> <BEA-002613> <Channel "Default" is now listening on 10.9.20.172:7000 for protocols iiop, t3, ldap, http.>
    <Sep 11, 2012 9:35:17 AM PDT> <Notice> <Server> <BEA-002613> <Channel "DefaultSecure" is now listening on 10.9.20.172:7002 for protocols iiops, t3s, ldaps, https.>
    However, when I open the console in https://server:7002/console, I get the following error in log file...
    <Sep 11, 2012 9:43:45 AM PDT> <Warning> <Security> <BEA-090481> <NO_CERTIFICATE alert was received from x.y.z.com - 10.37.10.54. Verify the SSL configuration has a proper SSL certificate chain and private key specified.>
    <Sep 11, 2012 9:43:45 AM PDT> <Warning> <Security> <BEA-090508> <Certificate chain received from x.y.z.com - 10.37.10.54 was incomplete.>
    I do not understand why I am getting this error when I assume there is no need to install certificates on user's computers. Can't someone please explain what is going on? Thanks in advance.

    <?xml version='1.0' encoding='UTF-8'?>
    <domain xmlns="http://www.bea.com/ns/weblogic/920/domain" xmlns:sec="http://www.bea.com/ns/weblogic/90/security" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wls="http://www.bea.com/ns/weblogic/90/security/wls" xsi:schemaLocation="http://www.bea.com/ns/weblogic/90/security/extension http://www.bea.com/ns/weblogic/90/security.xsd http://www.bea.com/ns/weblogic/90/security/xacml http://www.bea.com/ns/weblogic/90/security/xacml.xsd http://www.bea.com/ns/weblogic/90/security http://www.bea.com/ns/weblogic/90/security.xsd http://www.bea.com/ns/weblogic/920/domain http://www.bea.com/ns/weblogic/920/domain.xsd http://www.bea.com/ns/weblogic/90/security/wls http://www.bea.com/ns/weblogic/90/security/wls.xsd">
    <name>nctcis</name>
    <domain-version>9.2.3.0</domain-version>
    <security-configuration>
    <name>nctcis</name>
    <realm>
    <sec:authentication-provider xsi:type="wls:default-authenticatorType">
    <sec:name>DefaultAuthenticator</sec:name>
    <sec:control-flag>SUFFICIENT</sec:control-flag>
    </sec:authentication-provider>
    <sec:authentication-provider xsi:type="wls:default-identity-asserterType">
    <sec:name>DefaultIdentityAsserter</sec:name>
    <sec:active-type>AuthenticatedUser</sec:active-type>
    </sec:authentication-provider>
    <sec:role-mapper xmlns:xac="http://www.bea.com/ns/weblogic/90/security/xacml" xsi:type="xac:xacml-role-mapperType"></sec:role-mapper>
    <sec:authorizer xmlns:xac="http://www.bea.com/ns/weblogic/90/security/xacml" xsi:type="xac:xacml-authorizerType"></sec:authorizer>
    <sec:adjudicator xsi:type="wls:default-adjudicatorType"></sec:adjudicator>
    <sec:credential-mapper xsi:type="wls:default-credential-mapperType"></sec:credential-mapper>
    <sec:cert-path-provider xsi:type="wls:web-logic-cert-path-providerType"></sec:cert-path-provider>
    <sec:cert-path-builder>WebLogicCertPathProvider</sec:cert-path-builder>
    <sec:name>myrealm</sec:name>
    </realm>
    <default-realm>myrealm</default-realm>
    <anonymous-admin-lookup-enabled>true</anonymous-admin-lookup-enabled>
    <credential-encrypted>{3DES}PyUkjWRp8JGpk75BYSbvQ6OWYgA9SZq2nj2IuENa2vxrMy835GMRZ+GGKhJiWapjt0mMC2ohcxxlIMNUZJUH2gCjbB5kQUmA</credential-encrypted>
    <node-manager-username>system</node-manager-username>
    <node-manager-password-encrypted>{3DES}KmaZDZGQC6spYVY12CbJGA==</node-manager-password-encrypted>
    </security-configuration>
    <jta>
    <timeout-seconds>1800</timeout-seconds>
    <abandon-timeout-seconds>3600</abandon-timeout-seconds>
    <max-transactions>100000</max-transactions>
    <max-resource-unavailable-millis>100000</max-resource-unavailable-millis>
    </jta>
    <log>
    <name>nctcis</name>
    <file-name>e:/netcracker/logs/wl-domain.log</file-name>
    <file-min-size>5120</file-min-size>
    </log>
    <server>
    <name>nctcisAdmin</name>
    <ssl>
    <enabled>true</enabled>
    <hostname-verifier xsi:nil="true"></hostname-verifier>
    <hostname-verification-ignored>false</hostname-verification-ignored>
    <client-certificate-enforced>true</client-certificate-enforced>
    <two-way-ssl-enabled>false</two-way-ssl-enabled>
    <server-private-key-alias>tcisdevbpagov_cert</server-private-key-alias>
    <server-private-key-pass-phrase-encrypted>{3DES}T21dXO5l79SRI+xSmGOE+A==</server-private-key-pass-phrase-encrypted>
    <use-server-certs>false</use-server-certs>
    </ssl>
    <log>
    <name>nctcisAdmin</name>
    <file-name>e:/netcracker/logs/weblogic.log</file-name>
    <file-min-size>5120</file-min-size>
    </log>
    <listen-port>7000</listen-port>
    <web-server>
    <name>nctcisAdmin</name>
    <web-server-log>
    <name>nctcisAdmin</name>
    <file-name>e:/netcracker/logs/access.log</file-name>
    <file-min-size>5120</file-min-size>
    </web-server-log>
    </web-server>
    <listen-address>tcis.dev.bpa.gov</listen-address>
    <key-stores>DemoIdentityAndDemoTrust</key-stores>
    <custom-identity-key-store-file-name>E:\bea\jdk150_12\bin\tcisdevbpagov_identity.jks</custom-identity-key-store-file-name>
    <custom-identity-key-store-type>JKS</custom-identity-key-store-type>
    <custom-identity-key-store-pass-phrase-encrypted>{3DES}T21dXO5l79SRI+xSmGOE+A==</custom-identity-key-store-pass-phrase-encrypted>
    <custom-trust-key-store-file-name>E:\bea\jdk150_12\bin\tcisdevbpagov_trust.jks</custom-trust-key-store-file-name>
    <custom-trust-key-store-type>JKS</custom-trust-key-store-type>
    <custom-trust-key-store-pass-phrase-encrypted>{3DES}I++r0/FEMRGFrqF47pYZJA==</custom-trust-key-store-pass-phrase-encrypted>
    </server>
    <embedded-ldap>
    <name>nctcis</name>
    <credential-encrypted>{3DES}i51JYfmoGyFTxPjiCjjtXWwza1t13k56Ls7fmdqtKB0=</credential-encrypted>
    </embedded-ldap>
    <configuration-version>9.2.3.0</configuration-version>
    <app-deployment>
    <name>NetCracker</name>
    <target>nctcisAdmin</target>
    <module-type>ear</module-type>
    <source-path>applications\NetCracker</source-path>
    <security-dd-model>DDOnly</security-dd-model>
    <staging-mode>nostage</staging-mode>
    </app-deployment>
    <app-deployment>
    <name>pictures</name>
    <target>nctcisAdmin</target>
    <module-type>war</module-type>
    <source-path>e:\pictures</source-path>
    <security-dd-model>DDOnly</security-dd-model>
    <staging-mode>nostage</staging-mode>
    </app-deployment>
    <jms-server>
    <name>NCJMSServer</name>
    <target>nctcisAdmin</target>
    <temporary-template-resource>NCJMSModule</temporary-template-resource>
    <temporary-template-name>NetCrackerTemplate</temporary-template-name>
    <message-buffer-size>100000</message-buffer-size>
    </jms-server>
    <self-tuning>
    <max-threads-constraint>
    <name>MaxThreadsConstraint</name>
    <target>nctcisAdmin</target>
    <count>40</count>
    </max-threads-constraint>
    <work-manager>
    <name>default</name>
    <target>nctcisAdmin</target>
    <max-threads-constraint>MaxThreadsConstraint</max-threads-constraint>
    <work-manager-shutdown-trigger>
    <stuck-thread-count>1000</stuck-thread-count>
    </work-manager-shutdown-trigger>
    </work-manager>
    </self-tuning>
    <jms-system-resource>
    <name>NCJMSModule</name>
    <target>nctcisAdmin</target>
    <sub-deployment>
    <name>BEA_JMS_MODULE_SUBDEPLOYMENT_NCJMSServer</name>
    <target>NCJMSServer</target>
    </sub-deployment>
    <descriptor-file-name>jms/ncjmsmodule-jms.xml</descriptor-file-name>
    </jms-system-resource>
    <admin-server-name>nctcisAdmin</admin-server-name>
    <jdbc-system-resource>
    <name>NetCrackerDataSource</name>
    <target>nctcisAdmin</target>
    <descriptor-file-name>jdbc/NetCrackerDataSource-5713-jdbc.xml</descriptor-file-name>
    </jdbc-system-resource>
    <jdbc-system-resource>
    <name>NetCrackerDataSourceNonTX</name>
    <target>nctcisAdmin</target>
    <descriptor-file-name>jdbc/NetCrackerDataSourceNonTX-6926-jdbc.xml</descriptor-file-name>
    </jdbc-system-resource>
    </domain>
    Edited by: user6904153 on Sep 12, 2012 6:57 AM

  • Implementing interface views

    I have to add a main view to the portfolio items and integrate  the view WI_DMS of the web dynpro component DMS_DPR to the same. When I try to do it, it says  'WI_DMS does not implement a valid interface". Is there any way to implement the valid interface dynamically? PLease help.

    >i have been using ( implementing ) interfaces in the components, for example i used iwd_value_help. however i still have no clarity how WD framework is able to communicate with the component implementing interface iwd_value_help.
    Web Dynpro can create a component usage based upon the interface type alone.  This is very similar to normal ABAP OO when you create/get an instance of a class but only know the interface.  Basically this is polymorphism at the component level.
    >the basic question here is, what is wd framework, is it class implementing interfaces generated when we create views and other stuff. and this class( WD fw ) is going to call these implemented methods of the interface??
    Simple answer: yes, exactly as you describe.  Everything relates back to generated and local classes.  The framework can interact with them becuase all the generated classes implement SAP provide framework interfaces.

  • Troubles implementing SAP Note 765494

    All,
    I am trying to implement note 765494, but I have troubles implementing it.
    The note tells me to do the following:
    <b>12. Extend the private section of the CL_PO_ITEM_HANDLE_MM class to include the PO_EKPVX_HASH_TABLE attribute with the following attributes:
    a) Attribute: PO_EKPVX_HASH_TABLE
    b) Level: Static Attribute
    c) Visibility: Private
    d) Description: Hashed X data for EKPV
    e) Choose 'Direct Type Entry' to go to the definition of the Private Section. Maintain the following values:
               TYPES:
                BEGIN OF po_ekpvx_hash_entry,
                  item TYPE REF TO cl_po_item_handle_mm,
                  data TYPE mepo_ekpvx,
                END OF po_ekpvx_hash_entry .
               CLASS-DATA:
                po_ekpvx_hash_table TYPE HASHED TABLE OF
                        po_ekpvx_hash_entry WITH UNIQUE KEY item .</b>
    However, in the classbuilder the button with wich to jump to direct type entry is greyed out.
    My question is how to maintain direct types in se24 for this class.
    Thanks in advance
    Bert

    Hi rena,
    I did solve the problem by switching off the modification assistant.
    I hpe this works for you too.
    Regards,
    Bert

  • Perspective for Java technologies : implementing interface on late.

    In Java, to implements the adapter pattern's; we have to create a new class that have a link with the adaptee class and implements the adapter interface.
    class MyAdapter implements IAdapter
          public MyAdapter( Adaptee a );
    }or, if we need protected methods :
    class MyAdapter extends implements IAdapter
         public MyAdapter( Adaptee a );
    }then, to call the method void foo( IAdapter i ); ;
    we have to do xxx.foo( new MyAdapter( adaptee ) );it could be simpler if java allowed to implement interfaces after defining the java class.
    public class Adaptee
    }and then, in another file, something like,
    implementation of  IAdapter for class Adaptee
    }would be equivalent to
    public class Adaptee implements IAdapter
    }The advantage of the first method is that you can adapt very easy external classes from external jar file.
    thank's for coments.

    An interface is a contract which tells the compiler
    that a class that implements it implements a set of
    method signature which perform certain actions.That's right, but my idea is not to change the interface, but to change the external class, making it implements the existing interface.
    If you overlay an interface on someone else's class,
    the signature match (if there is one) could happen by
    coincidence. There's no guarantee that a method with
    a signature that matches one in your interface
    actually has the same function.I didn't say that an external class should be viewed as an interface without a specific implementation of this interface for the external class. But, instead of making a new class extending the first and implementing the interface, just define a specific implementation of the interface for this class, as if it was make at class declaration.

  • Implementation interface

    Hi guys. I have a test on array and inheritance and polymorphism. I didn't quite understand what is the benefit of implementing interfaces.
    Something like this:
    public class static Child extends Parent implement A,B,C
    Where A,B,C are interfaces.
    I need to get this straigth before the final test tomorrow. Thanks a lot.

    By implementing an interface, a class declares what it does. This means that the compiler and other classes can determine whether that class is suitable for some operations.
    So given your example Child which implements interfaces A, B, and C, there could be another class with method:
    public boolean doSomething(A aclass) {
    }This method can be given an instance of your "Child" class, or a different class which also implements the A interface.
    Interfaces say what a class does, as opposed to how it does it.

  • No implementation interfaces created using jaxb 2.0 ?

    Hi,
    I've downloaded the jaxb 2.0 RI and am trying to follow the short tutorial at http://java.sun.com/developer/technicalArticles/WebServices/jaxb/index.html.
    On trying to bind the schema via xsj,sh, which also is meant to generate the implementation interfaces (in an impl directory), I see these aren't created - the other classes are generated OK. Where or how should they be created ?
    thanks

    I am on the same boat. Have you found the answer to this?
    Thanks,
    Juan

  • Trouble with interface class

    Hi there,
    for a school project we're building a helicopter which can be controlled via the computer. We're going to connect some wires to the remote control of the helicopter and the wires we also connect to a LabJack (a digital/analog converter). Via java we can give signals to this labjack and control so the helicopter. Only one thing: I've downloaded the library for labjack for java. You can see this labrary, it called LabJackJava: http://www.teravation.com/downloads/LabJackJava.zip
    In it is a few classes and one of them is called LabJack (this is in fact a interface). In the interface there is a method called: void setAO(int channel, float value) throws LabJackException;
    This method I'm going to need to set the voltage on the wires. For compiling I use the program BlueJ (which is a object-orientated compiler). But because the the class LabJack is a interface, I cannot call the method setAO(). How can I solve this?? I also had some trouble with the System.loadLibrary("ljackj"); in the class LabJackDriver. I copied the file ljackj.dll into the folder system32 (windows) and it still doesn't work... Is this dll essential for the working of the class LabJack??? How can I solve this???
    Please help me!!
    Thanks!
    Héctor van den Boorn

    This is a forum for the Java programming language, not for every program and library ever written in Java. The LabJack site has a support area and forum, which should be the right place to seek a solution.
    That said, the documentation indicates that you obtain a LabJack reference from the appropriate method of LabJackFactory. The reference returned will be that of a platform dependent concrete class that implements the interface.
    db
    edit Oh, I see you have a history of not replying to responses on your posts. This was exceptionally bad, 9 responses and not a peep out of you.
    [http://forums.sun.com/thread.jspa?threadID=5242071]
    Fine. One for the blacklist.
    Edited by: Darryl.Burke

  • Implements interface method at the derived class

    Hi all.
    I have a class (Derived) that extends another class (Base).
    In the base class (Base) there is a method f() with its implementation.
    In the interface (C) there is also f() method exactlly like in the base class (Base).
    The derived class (Derived) is implements the interface (C).
    My question is:
    Do i have to implement the method f() in the derived class (Derived) ?

    My guess is that you probably have to, even if it's just to call the parent's method.
    This all sounds pretty sketchy. Why don't you just make the BASE class implement your interface?

  • Extend abstract class & implement interface, different return type methods

    abstract class X
    public abstract String method();
    interface Y
    public void method();
    class Z extends X implements Y
      // Compiler error, If I don't implement both methods
      // If I implement only one method, compiler error is thrown for not
      // implementing another method
      // If I implement both the methods,duplicate method error is thrown by 
      //compiler
    The same problem can occur if both methods throw different checked exceptions,or if access modifiers are different..etc
    I'm preparing for SCJP, So just had this weired thought. Please let me know
    if there is a way to solve this.

    Nothing you can do about it except for changing the design.
    Kaj

  • Implements interface

    Hello,
    I use JDK 5.0 with netbeans 4.0 beta 2
    I get an error when I implement an interface like in this following example:
    public class MyClass extends javax.swing.JPanel implements java.awt.event.KeyListener {
    public MyClass () {
    The text message is:
    MyClassMyClass is not abstract and does not override abstract method key released in java.awt.event.KeyListener
    Thank you for your help
    Claude

    An interface defines a contract with implementors of the interface. An interface may only contain public constants and public, abstract methods. An abstract method is a method declaration with no implementation (code) contained within.
    If you implement an interface in your class, you must exactly duplicate the interface's method signature, including name, any parameters and the return type. Now, you do not necessarily need to actually place any code in the method, but you do at least need to have the method present in your class.
    As an example:
    public interface Foo {
    public void bar()
    public class FooImpl implements Foo {
    final public void bar() {
    // optional code here
    - Saish
    "My karma ran over your dogma." - Anon

  • Implements Interface Problem

    I am new to Java, hence I would like to know the reason behind the error produced by the codes given below:
    --- Scenario 1 ---
    public class MTServer{
    //Main Method
    // Creates a socket, accepts the socket.
    ServProtocol sp = new ServProtocol(client);
    sp.start(); // <-- No Problem
    public class ServProtocol extends Thread{
    @Overrides
    public void run(){}
    --- Scenario 2 ---
    public class MTServer{
    //Main Method
    // Creates a socket, accepts the socket.
    ServProtocol sp = new ServProtocol(client);
    sp.start(); //<-- Error Given - Method is undefined for start().
    public class ServProtocol implements Runnable{
    @Overrides
    public void run(){}
    The difference in the 2 scenarios were, one extends Thread, while the other implements Runnable.
    However, I do not understand the error behind it.
    Does the error persist because .start() is inherited from Parent Class when extends thread. However when implements Runnable, it does not provide function on this method?
    I would like to know how can I re-write the code so that I can retain the flexibility of Interface by implementing Runnable, as well as not having the error shown in Scenario 2.

    Don't post roughly what your code looks like because as here you introduce errors.
    Assuming your new class implements Runnable then it doesn't have a start method. You should instead pass it to a thread and start that. i.e.
    MyThingImplementingRunnable thing = new MyThingImplementingRunnable();
    new Thread(thing).start();

  • Derived class also implements interface?

    Hi guys,
    If a base class A implements an interface (e.g. Comparable), does a derived class of A also implement this interface (or is of this type e.g Comparable, if this is a more correct way to say it)??
    If so, would it be wrong to write "public class B extends A implements Comparable", because class A already implements it?
    I am aware of that class B will inherit methods from class B and that way have "compareTo()" method. But can objects of class B be plugged in for method parameter of Comparable ( someMethod(Comparable obj) )?

    LencoTB wrote:
    Hi guys,
    If a base class A implements an interface (e.g. Comparable), does a derived class of A also implement this interface (or is of this type e.g Comparable, if this is a more correct way to say it)??Yes. The way you said it is fine, although another way to say it is "Comparable is a base interface(or class) of derived class B"
    >
    >
    If so, would it be wrong to write "public class B extends A implements Comparable", because class A already implements it?Not necessarily, but it is unnecessary. The only reason you would do this is to specifically document that the class is changing the implementation of compareTo.
    >
    I am aware of that class B will inherit methods from class B and that way have "compareTo()" method. But can objects of class B be plugged in for method parameter of Comparable ( someMethod(Comparable obj) )?use "implements Comparable<B>"

  • Design Question - Class Must Implement Interface

    I'm not sure how to describe this in summary, really. I'd say that I sort of want multiple inheritance, but I don't want to be shot. :-P So let me describe the situation:
    I have an interface, DataEditingComponent<T>. The idea is that anything implementing the interface is capable of allowing the user to edit an object of type T. For example, a DataEditingComponent<Integer> would allow the user to input an integer. A DataEditingComponent<Map<SomeObj,Integer>> might represent an object capable of editing a table describing the number of instances of SomeObj. You get the idea. DataEditingComponent<T> describes three methods: getEditingData():T, setEditingData(T):void, and getDefaultEditingData():T. I'm assuming you can guess what those do.
    Well, the practical application of this interface is in the use of a Swing application. It provides a very clean and standardized way of adjusting the contents of components which edit data. Obviously, a JTextField would work about as well as a DataEditingComponent<String>, but for more complicated components (DataEditingComponent<GameWorldMap>, for instance), the standardized interface is very helpful.
    Since in practice everything that ever implements DataEditingComponent<T> extends JComponent, it would be nice to declare this as a requirement somehow. However, given that JComponent is extended into a number of various subclasses, I can't just go making DataEditingComponent<T> an abstract subclass.
    So far, the only conclusion I've reached is that I can take each and every JComponent subclass and extend it into an abstract subclass which implements DataEditingComponent<T>... but that's very ugly and quickly leads to other problems. And presently, I'm left casting things from one to the other, with which I am also not happy.
    So... any way out of this? Have I done something wrong design-wise? Or am I just stuck in a language limitation?
    Thanks for reading!

    I'm not sure how to describe this in summary, really.
    I'd say that I sort of want multiple inheritance,
    but I don't want to be shot. :-P So let me
    describe the situation:
    I have an interface, DataEditingComponent<T>. The
    idea is that anything implementing the interface is
    capable of allowing the user to edit an object of
    type T. For example, a DataEditingComponent<Integer>
    would allow the user to input an integer. A
    DataEditingComponent<Map<SomeObj,Integer>> might
    represent an object capable of editing a table
    describing the number of instances of SomeObj. You
    get the idea. DataEditingComponent<T> describes
    three methods: getEditingData():T,
    setEditingData(T):void, and
    getDefaultEditingData():T. I'm assuming you can
    guess what those do.
    Well, the practical application of this interface is
    in the use of a Swing application. It provides a
    very clean and standardized way of adjusting the
    contents of components which edit data. Obviously, a
    JTextField would work about as well as a
    DataEditingComponent<String>, but for more
    complicated components
    (DataEditingComponent<GameWorldMap>, for instance),
    the standardized interface is very helpful.
    Since in practice everything that ever implements
    DataEditingComponent<T> extends JComponent, it would
    be nice to declare this as a requirement somehow.
    However, given that JComponent is extended into a
    number of various subclasses, I can't just go making
    DataEditingComponent<T> an abstract subclass.
    So far, the only conclusion I've reached is that I
    can take each and every JComponent subclass and
    extend it into an abstract subclass which implements
    DataEditingComponent<T>... but that's very ugly and
    quickly leads to other problems. And presently, I'm
    left casting things from one to the other, with which
    I am also not happy.
    So... any way out of this? Have I done something
    wrong design-wise? Or am I just stuck in a language
    limitation?Hmm. The component is part of the view. The data is part of the model. Putting them together seems to go against the whole Model-View-Controller concept. You may want to have a look at how Swing separates the editing from the rendering from the model for complicated widgets such as JTable. The editors hava methods such as getEditorComponent() which returns the Component used to edit the data. Everywhere you are currently adding DataEditingComponent instances to your GUI, you can instead call a getDataEditingComponent() method, which can require that the returned object is a JComponent.

Maybe you are looking for