Interface creations Problem

I am new to interface design. I have a main class (class A) instantiate a new contructor from class B which extends JPanel that draw images from a newly instantiated class C. But in my class A, when load a file, I instantiates a new constructor class D. This class D perform calculation which the data collected will be passed to class C to redraw the image. I know that I need to create an interface to perform this (from class D to class C) but I don't know how. Please Help!
Example:
class A extends JFrame{
public A()
new B();
//when I load a file from JFileChooser,
new D();
public static void main(String args[])
class B extends JPanel
public B()
new C();
class C
public C()
//draw image
//draw line on image (coordinates of line from class D)
class D
public D()
//perform calculation for class C to draw.
From the above example, how do I create interface for class A so that I can perform the draw line when a file is loaded?

I don't quite understand what you are saying. So, you have class A, which extends JFrame. In the class A constructor, a new class B (extending JPanel) is instantiated. In the class B constructor, a new class C is instantiated, the purpose of C being to draw images. Additionally, when you choose a file, you create a new instance of D which sends calculation results to C so that C can draw the image.
Well, there are a number of ways to do stuff like this. The following code is just one particular way. I tried to keep A, B, C, and D in my example, and I tried to keep it structured just like your original code:
    public class A extends JFrame {
        protected MyB;
        public A () {
            // Create a new B instance, store it in MyB.
            MyB = new B();
        // I'm just assuming this method gets called after the
        // JFileChooser returns, and that ChosenFileInfo is any
        // information that D needs to know about the file. This
        // implementation is just for illustrative purposes.
        public void FileWasChosen (ChosenFileInfo f) {
            // Create a new D, passing file info and a C to it.
            D MyD = new D(f, MyB.getC());
    public class B extends JPanel {
        protected MyC;
        public B () {
            // Create a new C instance and keep track of it in MyC.
            MyC = new C();
        public C getC () {
            // Return the C instance created in the B constructor.
            return MyC;
    public class C {
        void draw (DrawParameters p) {
            // Draw using info in p.
    public class D {
        public D (ChosenFileInfo f, C painter) {
            // Perform calculations, pass them to the provided C.
            painter.draw(performCalculations(f)); 
        public DrawParameters performCalculations (ChosenFileInfo f) {
            // Perform calculations, return results.
    };Now, you could, say, decide to pass an instance of B to the D constructor, and let D take care of getting a C instance from B. But, regardless of the way you implement your program, the key thing to notice in my example code is the method getC() in class B.
Note that, in the above code, B stores a reference to the C instance that was created in its constructor. It stores this reference in the variable "myC". Then, the method B.getC() returns the C that was created when a new B was constructed. (As an aside, since getC() allows you to "access" the protected member MyC in B, getC() is called an "accessor" method).
Now we have a way to get the C that was created by the B and pass it along to the D. As a matter of fact, we have a way to get that C and pass it to ANY other method that needs it for something. We could, say, have a class E that also did some other calculations. We could do something like:
    MyE = new E(MyB.getC());
    ...Know what I mean?
Now, you mentioned needing to create an "interface". An interface is sort of like a contract. The terms of the contract are a set of methods that any class implementing the interface must provide. So, if you wanted to apply this to your code, you could do something like:
    public interface CProvider {
        public C getC ();
    };Now, you could rewrite the code for B like so:
    // Notice that B now "implements CProvider"
    public class B extends JPanel implements CProvider {
        protected MyC;
        public B () {
            MyC = new C();
        public C getC () {
            return MyC;
    };Since B is implementing CProvider, it is bound by the terms of the CProvider "contract" to provide a method "public C getC()". As a matter of fact, if you comment out the getC method code in B, but you still implement CProvider, you'll get a compiler error.
To take advantage of this revised B that implements CProvider, we can rewrite D like so:
    public class D {
        public D (ChosenFileInfo f, CProvider cprov) {
            // Perform calculations, and send the results to the
            // C provided by cprov (a CProvider).
            cprov.getC().draw(performCalculations(f)); 
        public DrawParameters performCalculations (ChosenFileInfo f) {
            // Perform calculations, return results.
    // A.FileWasChosen needs changed slightly, too:
        public void FileWasChosen (ChosenFileInfo f) {
            // This time, we pass a CProvider to the D constructor,
            // rather than a C itself. Although this can be done
            // other ways, I'm doing it this way to illustrate the
            // usefulness of interfaces.
            D MyD = new D(f, MyB);
        };Specifying "CProvider" as the type of the second parameter to the D constructor means that we can pass ANY class that implements CProvider to the D constructor.
We could, now, write another CProvider class that is completely unrelated to B except for the fact that it has a method getC():
public class Bonkers implements CProvider {
    protected C c;
    public Bonkers () {
        c = new C();
    public C getC () {
        return c;
};We can now pass an instance of Bonkers to the constructor of D, just like we passed an instance of B before. From D's point of view it does not matter what class you pass to it... as long as the class implements the CProvider interface, D will be happy.
On another note, you shouldn't name your classes A, B, C, and D. You should name them names that indicate what the classes actually do. That was a confusing response to type.
I hope this helps.
Jason Cipriani
[email protected]
[email protected]

Similar Messages

  • Interface creation problem

    I want to create an interface in AR which will upload all the customer information..
    What are the following steps to be followed for creating an interface ....and what are the tables to be hit in production.
    Awaiting your's feedback
    Saugata

    The tables to get customer data are :
    hz_parties,hz_cust_accounts,hz_cust_acct_sites_all,hz_party_sites,hz_locations,hz_person_profiles,hz_organization_profiles .
    Interface tables:
    ra_customers_interface_all
    ra_contact_phones_int_all
    ra_customer_profiles_int_all

  • Ivette manzur : Interface errors problems on cisco 3560

    Hello,
    I have a problem on one of the interfaces on a cisco 3560 switch. In fact, I set up a monitoring network recently (cacti), and I have a significant number of errors on the interfaces. the problem is that when I do a sh interface I see no errors, and even by making a clear counters it does not solve my problem .. I also changed the wiring with cat 6 cables but nothing has changed ..
    What are the main causes of errors on an interface of a switch? what should I do in this case?
    Thank you for your help in advance
    ivette manzur

    Hello,
    I've a e61i and I experience a similar problem. My phone work very well on WiFi network with no encryption as well as 64-bit wep.
    At home I've 2 wireless routers, both encrypted at 128 bits, one with WEP and the other with WPA. On both of them I can correctly obtain an IP thru DHCP, but the traffic do not go thru.
    By using IfInfo I think I discovered the reason of the problem (unless IfInfo is not working properly...) and it seems a bug related to the netmask, broadcast and gateway settings. The router is 192.168.15.1 and this is what I get:
    1) DHCP case -- I get two IP adresses: the 169.254.x.x and the one assigned to the router. DNS is also set properly, but both gateway, broadcast and netmask are set to 0.0.0.0 for both IPs.
    IP Addr: 169.254.162.106
    Netmask: 0.0.0.0
    Broadcast: 0.0.0.0
    Gateway: 0.0.0.0
    DNS1: 192.168.15.1
    IP Addr: 192.168.15.100
    Netmask: 0.0.0.0
    Broadcast: 0.0.0.0
    Gateway: 0.0.0.0
    DNS1: 192.168.15.1
    2) Static IP 192.168.15.64, netmask set to 255.255.255.0 and gateway and DNS set to 192.168.15.1. The 169.254.x.x disappears and I get only one IP which is set to:
    IP Addr: 192.168.15.64
    Netmask: 0.0.0.0
    Broadcast:192.168.15.255
    Gateway: 192.168.15.1
    DNS1: 192.168.15.1
    So in conclusion, it seems that with 128bit encryption, in the DHCP case gateway, broadcast and netmask are not assigned correctly! While in the Static IP case the netmask is still not assigned correctly!!!
    Hope this can help...
    --AP

  • Interface creation...[LDAP Authentication]

    Hi...All SAP Xi friends,
    i have to work on an interface creation with the following specifications:
          1.  SAP Enterprise Portal gives us an URL which contains UserID
          2.   You have to create an interface to read the URL,
          3.  Connect to LDAP server...from there come to know whether it is external or internal user, meaning if it exist in LDAP it is internal otherwise it is external user
          4.  If the user id is internal, interface has to create a file and place it at a particular location & create a webservice for this and expose to EP
           5. if not it should give an alert saying it is an external user id
             Please help me out how to start and what to do..!
             Thank you.

    ? Why is the Loginid cn=dsameuser,ou=DSAME, and not the uid the of the user i use?
    This is strange you should see the loginid of the user ..
    try directly logging in using
    http://server:port/amserver/login?org=orgname, this should present a list of the auth modules you have enabled.
    ?Has anyone else got the same warning at the Loginchannel, using the "display_AuthLDAP.html" instead of the original "display.html" ? i tried it at two different machines, but the same error occurs.
    I have used it and worked fine for me.
    ? What else can I do to make the LDAP Authentication work?
    Is bind as Directory Manager absolutely necessary or have you setup your external ldap for anonymous bind. If that is the case then you don't need to bind.
    One other thing you can do is enable debug logging. Change the logging level in /opt/SUNWam/lib/AMConfig.properties to message and restart the server. This should give you additonal information.

  • Interface creation and LDAP authentication ...

    Hi...All SAP friends,
    i have to work on an interface creation with the following specifications:
    1. SAP Enterprise Portal gives us an URL which contains UserID
    2. You have to create an interface to read the URL,
    3. Connect to LDAP server...from there come to know whether it is external or internal user, meaning if it exist in LDAP it is internal otherwise it is external user
    4. If the user id is internal, interface has to create a file and place it at a particular location & create a webservice for this and expose to EP
    5. if not it should give an alert saying it is an external user id
    Please help me out how to start and what to do..!
    Thank you.

    Hi,
    These are the main steps,
    ***Assume that you know basic of authentication methods and how to define those in Apex
    01. Create a function to authenticate the user
    a. Check on the database whether user is exists
    b. If exists then authenticate that user with LDAP
    c. If user doesnot exists or authenticate failed then return false
    d. If user exists and authentication success then return trueSignature of the function
    FUNCTION <fucntion name> (p_username VARCHAR2, p_password VARCHAR2)
    RETURN BOOLEAN;
    * Makesure that you do both inside the one procedure
    02. Create another function to check the page level authorization(if you need pagelevel verification. But if all users has same permissions on the aplication this is not necessary)
    03. Create a new authentication
    a.Go to Application Builder
    b.Shared Component
    c. Authentication Schemes(under Security)
    d. Click "Create"
    e. Select "From Scratch"
    f. Proceed with the wizard and define "*Page Sentry Function*" (Only when you ahve page level authorization- BAove 2) and "*Authentication Function*"04. Set new authentication schema to current
    a. Goto "*Change Current*" Tab
    b. Sleect the new schema from the list
    c. Click Next and proceed with wizard.
    Thanks,

  • Database creation problems

    Help!! I have installed 8i on RH Linux 6.1 and followed the "Friendly" guide steps, it worked perfectly. However when I try to create a database using the Database assistant, I get an error "Oracle Not Logged on" I've reinstalled twice and still have the same problems - can anyone help?
    Thanks for any suggestions/help!
    null

    This problem doesn't just occur on Linux. I have encountered the same on both Digital Unix and HP/UX. I finally gave up and told it to just create the scripts. Looking at the scripts, there are a number of different problems depending on the items that you choose to install and/or customizations to db setup, such as size and placing of files.
    To find them, I generated the scripts and then looked at the contents and used svrmgrl to individually run commands so that I could see the "real" error message.
    It's been awhile but I think the not logged on was a failure in the initial create database command... Or maybe it was the MAX_ENABLED_ROLES being too small in the default init file to support some of the products... Or the rollback segments being created as private and not being automatically added to the init before the assistant does a shutdown and restart... Or it creating the rollback segment tablespace not the size and parameters that I requested...
    You may guess by now I wasn't too impressed by the dbassist program. All I can say is doesn't anyone believe in testing anymore? I have a hard time believing that anyone at Oracle actually tested running this product and actually using any of it's features.
    This really pissed me off because when I first saw the pretty GUI and nice interface I thought WOW, this is great, finally something to make database creation simpler than running all those commands and scripts.

  • Class/Interface creation by code..

    Hi all,
    I am trying to automate the creation of interface turned
    to SDN Forum and got help and was able to create interface thro code using SEO_INTERFACE_CREATE. But I was challenged by a problem. Every time the interface is created i have to click "Local Object" in
    "Create Object Directory Entry" dialog box.
    I was helped by SDN Forum once again and was asked to use
    SET PARAMETER ID 'DVC' to set it to '$TMP'.
    It worked fine. But when i try to add components/methods
    to the interface, it pops up that dialog box again!!!!
    I want to completely automated the creation of interface
    and the addition of methods without being bugged by a
    "Create Object Directory Entry" dialog box.
    Is it possible? Pls help.
    Thanks in advance.
    Regards,
    Anand.

    Try to use thf fm SEO_INTERFACE_CREATE_COMPLETE instead.
    It has a dev class parameter as import option.
    Regards,
    Ravi

  • Database creation problem on Windows XP

    Hello Readers
    I have installed ORACLE Database Engine on windows XP.
    I am facing problem in database creation.
    I have tryed wizard as well as mannual method.
    in wizard at 90% it gives an error "END-OF-FILE ON COMMUNICATION CHANNEL"
    although CD drive is in CR Rom drive.
    Please help me ....
    Rashid Masood Ashraf
    email: [email protected]

    After going to the properties as you suggested:
    Right now the Obtain an IP address automatically is checked
    I need to check the Use the following IP address:
    What should I enter for
    IP address:
    Subnet mask:
    Default gateway:
    Please help.
    Edited by: Nel Marcus on Dec 2, 2008 3:49 PM

  • Firewall Cisco ASA 5505 new interface license problem

    Hi
    I have one ASA 5505 with a Base License
    The problem is when i want to use a new named interface the system says "With current License maximum number of named interfaces allowed is 3. Name cannot be set for this interface"
    And the question is if with this base license the interface cannot be used or only cannot be named?
    here the output of my firewall:
    Cisco Adaptive Security Appliance Software Version 8.2(5)
    Device Manager Version 6.4(5)
    Hardware:   ASA5505, 512 MB RAM, CPU Geode 500 MHz
    Internal ATA Compact Flash, 128MB
    BIOS Flash Firmware Hub @ 0xffe00000, 1024KB
    Encryption hardware device : Cisco ASA-5505 on-board accelerator (revision 0x0)
                                 Boot microcode   : CN1000-MC-BOOT-2.00
                                 SSL/IKE microcode: CNLite-MC-SSLm-PLUS-2.03
                                 IPSec microcode  : CNlite-MC-IPSECm-MAIN-2.05
    0: Int: Internal-Data0/0    : address is e02f.6de6.7843, irq 11
    1: Ext: Ethernet0/0         : address is e02f.6de6.783b, irq 255
    2: Ext: Ethernet0/1         : address is e02f.6de6.783c, irq 255
    3: Ext: Ethernet0/2         : address is e02f.6de6.783d, irq 255
    4: Ext: Ethernet0/3         : address is e02f.6de6.783e, irq 255
    5: Ext: Ethernet0/4         : address is e02f.6de6.783f, irq 255
    6: Ext: Ethernet0/5         : address is e02f.6de6.7840, irq 255
    7: Ext: Ethernet0/6         : address is e02f.6de6.7841, irq 255
    8: Ext: Ethernet0/7         : address is e02f.6de6.7842, irq 255
    9: Int: Internal-Data0/1    : address is 0000.0003.0002, irq 255
    10: Int: Not used            : irq 255
    11: Int: Not used            : irq 255
    Licensed features for this platform:
    Maximum Physical Interfaces    : 8        
    VLANs                          : 3, DMZ Restricted
    Inside Hosts                   : Unlimited
    Failover                       : Disabled
    VPN-DES                        : Enabled  
    VPN-3DES-AES                   : Enabled  
    SSL VPN Peers                  : 2        
    Total VPN Peers                : 10       
    Dual ISPs                      : Disabled 
    VLAN Trunk Ports               : 0        
    Shared License                 : Disabled
    AnyConnect for Mobile          : Disabled 
    AnyConnect for Cisco VPN Phone : Disabled 
    AnyConnect Essentials          : Disabled 
    Advanced Endpoint Assessment   : Disabled 
    UC Phone Proxy Sessions        : 2        
    Total UC Proxy Sessions        : 2        
    Botnet Traffic Filter          : Disabled 

    Hi,
    The ASA5505 has with Base License the limitation of 3 Vlan interface of which 1 is also limited in access (shown by the above output mentioning DMZ Restricted)
    For an interface on the ASA to operate it must have a name with the command "nameif"
    If you already have 3 Vlan interfaces in use then with this license you wont be able to configure 4th Vlan interface without getting a license that supports more interfaces. I guess that would be the Security Plus license.
    I know that this has come as a surprise to several users that have posted here on the forums. I too think that its a needles "feature" in the ASA to limit the use of the device in such a way.
    - Jouni

  • Remittance challan creation problem in Cross company code scenario.

    I made to Advance  payment to Cross comany code while posting time we deduct the TDS amount. at the time remiottance challan creation  i got bellow error.please help to me
    No unpaid tax lines exist for the given selection criteria.
    Message no. 8I702
    Diagnosis
    The corresponding withholding tax line  &1& is not present in WITH_ITEM table.
    System Response
    For withholding tax recovered from the vendor, tax line is present in table BSIS, but the corresponding entry is missing in table WITH_ITEM , which is necessary for challan updation. Check the entries.
    Procedure
    check entries in table WITH_ITEM for the open tax items chosen for clearing.
    Edited by: TEEGALA SATISH on Jun 15, 2010 5:43 PM

    Hi ...Actually i am getting same problem in challan creation.. Did you get any solution? ...

  • Process order creation problem

    I am creating a process order . while creating the process order system is throwing error as Auto batch numbering not set up for material type XXXX in plant xxxx . System is not allowing to create process order.
    How to resolve the issue.

    Check in CORW   and switch off batch creation  to isolate the problem if needed.   Also see whether you have any batch managed compoents   for which you have set master data for automatic batch determination.
    There is no setting for material types and plant for batch.  May be the error message is not correct.  What is the message number?

  • BMW 335i ipod interface connection problem with ipod classic 80GB

    Hi all, i have a 2007 BMW 335i with dealer installed ipod interface, and i been using it since, it's simply i just connect ipod with the cable in the glove compartment and leave it there, and it charges and stanby, when i start up the car the audio jumps right to where i left off on the ipod and it also let me control it with iDrive. after about one and half year of usage, i think there is something wrong with my ipod or i dont know for sure, well here is the problem, when i start the car it will play music from the ipod and i can control it from iDrive and everything but after about 5-10 mins, the music stop, and my iDrive shows weird playlist, and i need to unplug the ipod and replug again to have it connect and then it will stop by itself, after 5-10 mins, any of you guys have a bmw with the ipod interface have this problem?? i dont really know if it's my ipod problem or my bmw ipod interface problem. anyone can help me with this? thank you!

    That is most likely going to be a problem with your iPod, not the interface.
    Have you tried Resetting the iPod? (hold down the menu and center buttons for six seconds).
    If that fails to work, try Restoring the iPod in iTunes.

  • New Excise Invoice Creation - Problem

    Hi All,
    I am facing problem in creation of Excise Invoice. I dont know the step by step process, can any one help me to get this ?
    Best Regards
    Chintesh Soni

    Hi Chintesh,
    if you are referring to a 100% tax invoice, please see note [887917|https://service.sap.com/sap/support/notes/887917] for 2 workarounds.
    All the best,
    Kerstin

  • Logical Standby Creation Problems "Create STatus Unknown"

    We are using Grid Control 10.2.0.3 on Oracle 10.2..0.3 databases, Windows 2003 sp2 machines.
    We have a primary and fsfo physical standby working properly. We went to create a logical standby on a separate server and had problems. it turned out that the listener on the server was not discovered on the target. we fixed that problem and finished the creation of the logical standby and it seems to be functioning properly now.
    However, the status on the data guard page for the logical standby shows Create Status Unknown and we are unable to proceed on to create an additional standby database for other purposes. We have tried removing the logical standby target and re-discovering it but status still shows Create Status Unknown.
    Is there any way to clear this status without having to drop the logical standby and completely recreate it.

    The status on the agent shows it uploading successfully.
    We resolved the issue by removing the logical standby from the configuration and selecting to retain the log apply. We then re-added the standby selecting to manage an existing standby database and the status went to normal.

  • Date of creation problem after making Bridge create TIFs with PS Image Processor.

    I went through about 100 files and did what I wanted in Camera RAW (started out with NEFs). Thereafter I had Bridge make TIFs of all the files in the folder using the PS Image Processor.
    Now, looking at the TIF folder in Bridge, I find that about 80 of them has a wrong creation date (I checked the Preferences and I have asked for the date of creation - and not the date of modification). As I watch (several minutes) Bridge changes some of the dates to the ones known to me to be correct - but not all. If I close Bridge, restart Bridge and open the folder again the same happens, i.e. it starts all over. Even stranger is that the Windows Pathfinder have problems with the same files - i.e. does not show the date of creation at all.
    The date of these 80 files are all the same - and they have been edited over several days!
    I have done a lot of work on those files and would hate to start all over. I checked and of course the dates are the original in the RAW folder that I started out with.
    I am sure that I do not have any bugs in my PC.
    Can I remedy this i any way? I hate to have wrong dates on my files.
    What can I have done to cause this? Can anyone help me? Thanking You in advance.
    Git

    Thank You again.
    Yes, I have also purged the cache. More than once and again this morning. It does not change the result. Bridge still goes from the date January 13th 2013 to the correct date of creation when I look at the separate thumbnails - and back again when I scroll down the page and subsequently scroll up again!
    Thus it seems that Bridge knows the date that the camera set but somehow this foolish January date keeps coming back.
    All the folders with NEFs have correct dates - also the ones where I have imported the files from camera to pc in 2013! Only my TIFFs have this problem.
    Rigth now I am having Norton 360 run a complete system scan. When that is done I will inactivate Norton (I know that I cannot have 2 antivirus softwares and firewalls run simultaneously on the PC) and instead run a complete scan with Lavasoft Adaware Pro. I have also used Norton Utilities and found no problems. Plus Malwarebytes Antimalware and Superantispyware. No problems.
    If "date file created" is the date that the file was modified, it would not help me much. I often go back to a file and play with it again and if I have understood correctly, then this date would change again. I want to see the date of capture ("date created"). Also, by now the problem afflicts at least 1000 files. It would be impossible to do single file manual corrections of dates on so many files.
    Update: While I have been writing this, an opened folder with only 36 files has changed the dates to the correct date of capture. I could also scroll up and down without the dates changíng in this small folder. But when I closed Bridge, restarted it and looked at the folder again Bridge again did need minutes to get all the dates rigth. Maybe I have a pc capacity problem instead of a software problem? But why on earth would this specific wrong date result from a too weak pc.?
    Maybe I should just give up and reinstall PS?
    Sorry if I trouble You with a ridiculous problem.
    Git

Maybe you are looking for

  • Incompatible Format question

    Thanks in advance for any help. My problem is that I have a .mov file that I'm trying to put into DVD studio pro and I keep getting the "incompatible format" message. I don't know why though. Here's how I made the .mov file though. (By the way, this

  • Advance Table - Add Row button and coloumn issue

    Hi all, I have created Advanced Table wth four coloumns. for two columns item style as messagtextinput and the rest are same as DATE. But when the page is rendering the table columns shows as messagestyletext , which means messagetextinput style item

  • JDeveloper / ADF

    Infrastructure_ OAS - Oracle Application Server* Release# 10.1.2.3 JInitiator: Version 1.3.1.26 Forms/Reports: Version 10.1.2.3.0 Developer's machine* Oracle Developer Suite 10g Release 2 (10.1.2) Patch Set 3 (10.1.2.3.0) Forms [32 Bit] Version 10.1.

  • Bluetooth Configuration Question

    My question is regarding Bluetooth Headset configuration on a Blackberry device.  I have the Blackberry Curve 8310.  I have an automobile that has a Bluetooth system to be used for hands free communication.  Additionally I have a Plantronics Bluetoot

  • Help with the automatically generated .mov

    I'm using IMovie 4. Each movie project, once saved, automatically generates a .mov file of the project, with an amazingly small file size, 720 X 480 dimensions, and fantastic resolution. I was able to upload and embed one such file into my personal w