Calling object methods from other objects

ok im trying to build a little windows application which shows a few thumbnails of pictures in a folder.
I have a mainForm class that runs all the jFrame and menus, status bar etc, it has 2 jPanes, one with a jTree that browses the directories and the other is set blank and adds a few custom component objects depending on how many images are in the directory it does contains a few objects all from one custom component class that shows an image and a label below it.
What i want to do is call the mainForm statusbar from within my custom component class. I have tried many things but cant seem to do it.
How do i do this in java? or can anyone point me in the right direction for some reading material, websites etc?
thanks

if i have correctly understood what you are asking (big assumption)...
you could just pass a reference to the main form into the custom class when you construct it (the custom class) - but this introduces unnessary coupling between the two classes and this approach will quickly get messy and hard to maintain.
a better approach is to use the Mediuator pattern.
have a look at
www.mindspring.com/~mgrand/pattern_synopses.htm for example.

Similar Messages

  • Calling a method from an object

    Hi guys,
    I'm trying to use the "testTemperature" method to access the object type "WeatherStation" (already created in my project) and return its initial temperature value.
    I keep getting an error message when i do it. Can someone tell me where i'm going wrong?
    public class Reporter
        // instance variables
        private WeatherStation ws;
        private WeatherReport wr;
        /** Constructor for objects of class Report
        public Reporter()
            ws = new WeatherStation("Tropical");
            wr = new WeatherReport();
        /** Returns initial temperature value
        public int testTemperature()
            return WeatherStation.temperature;
         * Constructor for objects of class Report
        public Reporter(String where)
            ws = new WeatherStation(where);
            wr = new WeatherReport();
    }

    flounder wrote:
    You are trying to access temperature statically. You have created a WeatherStation object so you should accessing temperature via that object instead.Yeah, that was what i wanted to do.
    I have now sorted that out now.
    I've got a problem though.....
    When i compile, it says there is no syntax error, but when i run the method, it gives me this error message ---> http://i36.tinypic.com/14ne3wl.jpg
    Here's my code....
    public class Reporter
        // instance variables
        private WeatherStation ws;
        private WeatherReport wr;
        private WeatherStation temperature;
        /** Constructor for objects of class Report
        public Reporter()
            ws = new WeatherStation("Tropical");
            wr = new WeatherReport();
        /** Returns initial temperature value
        public int testTemperature()
            return temperature.getTemperature();
         * Constructor for objects of class Report
        public Reporter(String where)
            ws = new WeatherStation(where);
            wr = new WeatherReport();
    }Anyone got an idea where i'm going wrong?
    Edited by: LevelSix on Nov 28, 2008 10:17 AM

  • Calling a method in BPM Object from jsp page

    hi all,
    I try to call a method from BPM Object using <f:invokeUrl >
    I change server side method properties to yes.
    and then how can i get request and response object inside the BPM method.
    Thanks.

    Thanks for ur response,
    But i mention about BPM method inside BPM Object.
    i found this inside the documentation.
    methodName(Fuego.Net.HttpRequest request, Fuego.Net.HttpResponse response)
    i need to match above BPM method and <f:invokeUrl > tag. am i right?
    But i don't know how to create method with argument "Fuego.Net.HttpRequest request, Fuego.Net.HttpResponse response" inside BPM Object.
    I can't find any place to define method argument inside Oracle BPM studio.
    I don't know how to parse argument like "Fuego.Net.HttpRequest request, Fuego.Net.HttpResponse response"
    With Regards,
    Wai Phyo
    Edited by: user8729650 on Sep 9, 2009 7:03 PM
    Edited by: user8729650 on Sep 9, 2009 9:20 PM

  • Calling a method in BPM Object from jsf page

    Hi All,
    How do I call a method in BPM object from JSF page? Is it possible to invoke it in a manner similar to invoking a method from managed bean in JSF application?
    Please help.
    Thanks and Regards,
    Veronica

    You can use f:invoke (or f:invokea to with parameters)
    For ajax calls, you can use f:invokeUrl to get the URL to a particular method within your BPM object, although make sure the Server-Side Method property is set to Yes.
    http://download.oracle.com/docs/cd/E13154_01/bpm/docs65/taglib/index.html

  • Calling Methods from Business Object BUS2032

    Hi all,
              Is it possible to call methods from the Business Object BUS2032.
       If so, how can it be done?? 
    Regards,

    Hi Marv,
    you sure can. Here is an extract from the SAP Help. I found it at http://help.sap.com/saphelp_46c/helpdata/en/c5/e4ad71453d11d189430000e829fbbd/frameset.htm
    <b>Programmed Method Call</b>
    Call (fictitious) method Print of object type VBAK (sales document). The method receives the parameters Paperformat and Printertype as input.
    * Call method Print of object type VBAK
    * Data declarations
    DATA: VBAK_REF TYPE SWC_OBJECT.
    SWC_CONTAINER CONTAINER.
    * Create object reference to sales document
    SWC_CREATE_OBJECT VBAK_REF 'VBAK' <KeySalesDoc>
    * Fill input parameters
    SWC_CREATE_CONTAINER CONTAINER.
    SWC_SET_ELEMENT CONTAINER 'Paperformat' 'A4'.
    SWC_SET_ELEMENT CONTAINER 'Printertype' 'Lineprinter'.
    * Call Print method
    SWC_CALL_METHOD VBAK_REF 'Print' CONTAINER.
    * Error handling
    IF SY-SUBRC NE 0.
    ENDIF.
    Cheers
    Graham

  • Access object attributes using other object JNI native method

    Hi. I'm trying to change an attribute of object O1 from another object O2 without invoking a O1 method and without making the attribute as public or protected.
    The only possibility that comes to my mind for doing so is writting a JNI native method
    public class O1 {
    static public native changeAttribute (Object O2, Object newAttributeValue) ;
    that change the attribute memory reference, but all I've found about accesing attributes in JNI is about accessing the invoker attributes (in this case, O1).
    �Does any one know if it's possible to do so? Thanks.

    I know that is not a good practice but I cannot figure out another way.
    I'll try to explain the whole problem so you see the reason. I'm working with transactions, using objects as the data. An object can be opened for write by several transactions because the granularity for conflicts is not the object, is each of its attributes. As long as two transaction don't write the same attribute, they both can write. For writing, each transactions uses a private copy of the object. At committing, the actual copy of the object must be replaced by the committer one, but as far as the granularity is the object attributes, only each written attribute must be replaced (if not, only the last commit would be visible).
    This attribute replace must be done by the transaction manager as far as the transactional object is provided by the client. So what i was thinking was to use JNI or some trick like that to replace the object attributes transparently to the object.
    I hope the explain is clear, my english is a little asleep :-(.
    How to do it with reflection? I thought that was only for method calling. Anyway, there wouldn't be problems if the attributes are private?
    Thanks for answering.
    EDIT: I've been able to change a public field using reflection, but not the private one
    import java.lang.reflect.*;
    class Caca {
    public static void main(String[] args) {
    Integer r = new Integer(0);
    System.out.println("original: " + r.toString());
    modifyWidth(r, 300);
    System.out.println("modified: " + r.toString());
    static void modifyWidth(Integer r, int newValue ) {
    Field valueField; Class c = r.getClass();
    try {
    valueField = c.getField("value");
    valueField.set(r, newValue);
    } catch (Exception e) { System.out.println(e); }
    Message was edited by:
    dfasdfsdafsadfasdf

  • Connect to COM(OBJECTS/METHODS) FROM ABAP

    Dear all.
    How can I connect to COM objects/methods from abap?
    Could give me link to example.

    Yes this method raises and exception with this message
    Message ID:          FDT_CORE
    Message number:      085
    DO_IM_DATETIME is not in the context
    The method SET_VALUE corresponds to IF_FDT_CONTEXT. This is the method's calls
          lv_name = 'DO_IM_DATETIME'.
          TRY.
              o_context->set_value( iv_name =  lv_name
                                    ia_value = lv_element_tzone ).
            CATCH cx_fdt INTO lx_fdt.
              RAISE incorrect_parameter.
          ENDTRY.
    I reactivate the aplication, the function, the expression and the data objects.
    But the method is still giving this exception.
    I have only this exception when I try to set up this two parameters:
    DO_IM_DATETIM of type Timepoint
    DO_IM_LANGU which is binding to the element type LANGU
    But in my BRFPlus Function Context I do have this two parameters.
    Thanks !

  • Calling stored procedures from entity object and application module

    Hello
    I've put in place an EntiyImpl base class containg helper methods to call stored procedures.
    I now need to call stored procedures from the application module.
    Apart from creating an application module base class and duplicating the helper method code is there a way
    to share the helper methods for calling stored procedures between the entity impl and application module impl ?
    Regards
    Paul

    Does the helper code depend on features of a particular entity object instance, beyond its database transaction?
    If so, I'm not sure I see how it could be used from an application module class.
    If not, here's what you do:
    Step 1:
    Parametrize the database transaction--you might even want to. So instead of
    protected myHelperMethod(Object someParam) {
    DBTransaction trans = getDBTransaction();
    change this to
    protected myHelperMethod(DBTransaction trans, Object someParam) {
    Step 2: make the method public and static--once you parameterize the DBTransaction, you should be able to do this.
    public static myHelperMethod(DBTransaction trans, Object someParam) {
    Step 3: Remove the method from your EntityImpl base class into a utility class:
    public abstract class PlSqlUtils {
    private PlSqlUtils() {}
    public static myHelperMethod(DBTransaction trans, Object someParam) {
    When you want to call the method from an application module, entity object, or even view object class, call
    PlSqlUtils.myHelperMethod(getDBTransaction(), paramValue);
    Unlike Transaction.executeCommand(), this lets you provide functionality like setting procedure parameter values, retrieving OUT parameter values, etc.
    Hope this helps,
    Avrom

  • Generically calling a method on an object

    Hello,
    I am trying to write a small utility method to generically call a method on an object.
    This is what I have.
        public static void doCall(Object o, String methodName, Object ... args){
            Class[] types = new Class[args.length];
            int i = 0;
            for(Object arg : args){
                types[i] = arg.getClass();
            try {
                Method m = o.getClass().getMethod(methodName, types);
                m.invoke(o, args);
            } catch (Exception e) {
                e.printStackTrace();
                throw new RuntimeException("Error dynamically calling method " + methodName + " on " + o.toString());
        }It doesn't work because it can't find the method. If I hard code the parameter types as "new Object[] {Double.TYPE}" it works fine (on methods that take a double).
    So, my question is, how can I generically set up the parameter types based on the types of the arguments?
    Thanks,
    ~Eric

    The problem is not on calling agr.getClass(), your primitive double is already autoboxed to a Double object. It is the doCall(...) method who expects an object, not a primitive. So when giving it a primitive value, java autoboxes it to the corresponding object type.
    This means your attempt will only work if the methods to call do not have any primitives as parameters.
    Test this code:
    public class GenericMethodCaller {
         public static void doCall(Object o, String methodName, Object ... args){
            Class[] types = new Class[args.length];
            int i = 0;
            for(Object arg : args){
                types[i++] = arg.getClass();
            try {
                Method m = o.getClass().getMethod(methodName, types);
                m.invoke(o, args);
            } catch (Exception e) {
                e.printStackTrace();
                throw new RuntimeException("Error dynamically calling method " + methodName + " on " + o.toString());
         public static void main(String[] args) {
              Callable callee = new Callable();
              callee.callabelMethod(10d);          
              GenericMethodCaller.doCall( callee, "callabelMethod", 10d ); // 10d gets autoboxed to a Double object.
    class Callable {
         public void callabelMethod(Double o) {
              System.out.println("callabelMethod(Double o) called");
         public void callabelMethod(double o) {
              System.out.println("callabelMethod(double o) called");
    }The output will be:
    callabelMethod(double o) called
    callabelMethod(Double o) called
    - Roy

  • Reading from other object

    Hi Guys,
    I dont know whether am following the correct way , I have a scenerio where I have to show in the report Blocking reasons . I have a field from DS Payment Block Key which is 0PMNT_BLOCK in BI. I have 7 Blocking reasons in one table called BSEG and I have enhanced my 0FI_AP_4 DS to include this 7 fields and mapped to 7 BI Objects 0BLCKRSN_PR for price 0BLCKRSN_QL for quality....Now bringing these fileds from BSEG effecting performance as each time the exit is calling. I do have a Text data source (0PMNT_BLOCK_TEXT) which is having same data as I need...So in order to get this Blocking reasons in to my report without enahcing from BSEG table Iam trying to read it from master data . but its not allowing me to do that....When I say read from master data for one of the info object 0BLCKRSN_PR and press F4 its showing no info object available for reading of master data....Can any one tell me why its showing this error...I do have a Master data object 0PMNT_BLOCK which is having the values A B D H M P , so I want to read the above object 0BLCKRSN_PR from this Object ...as P is for Price and so on....
    Do I need to take the seven info objects as attributes of 0PMNT_BLOCK ?
    If so , I didnt find a DS for attributes in ECC , I have only Text DS 0PMNT_BLOCK_TEXT....
    Please advice me what I need to do for this...Also please shoot me a reply If you ahve any more questions....

    the join produces more rows then the sum of it's parts (e.g. 154). For example:
    select owner, name
    from all_source
    where upper(text) like '%BINARY_INTEGER%'
    633 rows selected.
    select owner, type
    from all_source
    where upper(text) like '%PLS_INTEGER%'
    926 rows selected.
    select ds1.owner, ds1.name, ds2.type
    from all_source ds1 inner join all_source ds2 on (ds1.owner = ds2.owner and ds1.name = ds2.name and ds1.type = ds2.type)
    where upper(ds1.text) like '%BINARY_INTEGER%'
    and upper(ds2.text) like '%PLS_INTEGER%'
    5710 rows selected.
    select owner, count(name) as name_cnt
    from all_source
    where upper(text) like '%BINARY_INTEGER%'
    group by owner
    OWNER NAME_CNT
    SYS 577
    WWW 56
    2 rows selected.
    select owner, count(type)
    from all_source
    where upper(text) like '%PLS_INTEGER%'
    group by owner
    OWNER COUNT(TYPE)
    SYS 909
    WWW 17
    2 rows selected.
    this could be a solution then:
    select ds1.owner, ds1.name_cnt, ds2.type_cnt
    from (select owner, count(name) as name_cnt
    from all_source
    where upper(text) like '%BINARY_INTEGER%'
    group by owner) ds1 inner join (select owner, count(type) as type_cnt
    from all_source
    where upper(text) like '%PLS_INTEGER%'
    group by owner) ds2 on (ds1.owner = ds2.owner)
    OWNER NAME_CNT TYPE_CNT
    SYS 577 909
    WWW 56 17
    2 rows selected.

  • Calling BSP Application from Business Object?

    Hi,
    Can any one tried to call BSP Application from Business Object for showing in the Portal.
    I have the following Scenario:
    1. BSP Page: User will input the Date and Submit to store in the Database. and in this page the Workflow will be truggered and a Work item will be sent to the Next Level User.
    2. When he executes the Work Item it has to trigger the BSP Application and has to show in the Enterprise Portal.
    All this has to happen in the Enterprise Portal.
    If any one knows how to triggere from business object, please let me know.
    Thanks & Regards
    Sumanth

    Hi Vijay,
    Thanks for the information. Its long back i was working on this, but not successful,
    Now the similar requirement i need to develope in R/3.
    I checked the mentioned class in R/3 4.7, This class is not available. I hope this is only in CRM because of PC-UI.
    Any Suggesions how can i achieve this execution of BSP.
    In one of the document i saw the Business Object BUS1006 as an example but i could not locate the way to reutilize the similar way.
    Thanks & Regards
    Sumanth

  • JUNIT : how to call static methods through mock objects.

    Hi,
    I am writing unit test cases for an action class. The method which i want to test calls one static method of a helper class. Though I create mock of that helper class, but I am not able to call the static methods through the mock object as the methods are static. So the control of my test case goes to that static method and again that static method calls two or more different static methods. So by this I am testing the entire flow instead of testing the unit of code of the action class. So it can't be called as unit test ?
    Can any one suggest me that how can I call static methods through mock objects.

    The OP's problem is that the object under test calls a static method of a helper class, for which he wants to provide a mock class
    Hence, he must break the code under test to call the mock class instead of the regular helper class (because static methods are not polymorphic)
    that wouldn't have happened if this helper class had been coded to interfaces rather than static methods
    instead of :
    public class Helper() {
        public static void getSomeHelp();
    public class MockHelper() {
        public static void getSomeHelp();
    }do :
    public class ClassUnderTest {
        private Helper helper;
        public void methodUnderTest() {  // unchanged
            helper.getSomeHelp();
    public interface Helper {
        public void getSomeHelp();
    public class HelperImpl implements Helper {
        public void getSomeHelp() {
            // actual implementation
    public class MockHelper implements Helper {
        public void getSomeHelp() {
            // mock implementation
    }

  • "Create Simple document" from other objects

    Scenario: Creating a document using option "Create Simple document" from other objects
    I have created a document type and defined the object link for Functional Location with option "create simple document"
    When clicking on create icon on the additional data tab on IL02 screen, The system asks for the document type and then the file to be uploaded.
    The document type that i have defined has the Description filed as mandatory field and hence i am not able to create the document.
    However, for the Document type when i set the description field as not mandatory the system creates DIR. But this DIR has no description.
    Please let me know if there is a BADI, using which i could set the Functional location name as the description OR if there is some enhancement by which the user is asked to enter the description when creating the document.
    Warm Regards,
    Vivek Mohankumar

    Hi Vivek,
    After my tests I would like to inform you that this is                  
    the standard system behavior as the document description field is       
    maintained as mandatory in transaction DC10. Please note that for the   
    simple creation of documents this should not be set as a mandatory      
    field.                                                                               
    The creation mode can be defined in transaction DC10 for each object    
    under 'Define object links'.                                                                               
    Please note that the value "1" for the creation of documents is used    
    to enable a user to simple attache a word file to an object             
    without going to the transaction CV01n. Therefore the system behaviour  
    is different then creating a document by CV01n and attaching a          
    file to it. With simple creation mode there should not be any           
    mandatory fields as the user cannot enter anything during the creation  
    process.                                                                               
    However, you can change the behaviour how the document is created by    
    MM02 transaction if you change the customizing in transaction DC10      
    like this:                                                                               
    If you maintain the value "2" for creation of documents, the user is    
    put to transaction CV01n and then the description can be entered. So    
    maybe this would solve the issue.  
    Regarding a useful BADI I can only recommned you to test BADI DOCUMENT_OBJ1,
    DOCUMENT_OBJ2 or DOCUMENT_MAIN01 for fill the description field.
    I hope this information could be useful for you and help to avoid the   
    mentioned error message.                                                                               
    Best regards,
    Christoph

  • Calling a method from a super class

    Hello, I'm trying to write a program that will call a method from a super class. This program is the test program, so should i include extends in the class declaration? Also, what code is needed for the call? Just to make things clear the program includes three different types of object classes and one abstract superclass and the test program which is what im having problems with. I try to use the test program to calculate somthing for each of them using the abstract method in the superclass, but its overridden for each of the three object classes. Now to call this function what syntax should I include? the function returns a double. Thanks.

    Well, this sort of depends on how the methods are overridden.
    public class SuperFoo {
      public void foo() {
         //do something;
      public void bar(){
         //do something
    public class SubFoo extends SuperFoo {
       public void foo() {
          //do something different that overrides foo()
       public void baz() {
          bar(); //calls superclass method
          foo(); //calls method in this (sub) class
          super.foo(); //calls method in superclass
    }However, if you have a superclass with an abstract method, then all the subclasses implement that same method with a relevant implementation. Since the parent method is abstract, you can't make a call to it (it contains no implementation, right?).

  • Calling a method from a static method

    hello all,
    I'm calling a non-static method from a static method (from the main method). To overcome this i can make the method i am calling static but is there another way to get this to work without making the method that is being called static?
    all replies welcome, thanks

    When you call a non-static method, you are saying you are calling a method on an object. The object is an instance of the class in which the method is defined. It is a non-static method, because the instance holds data in it's instance variables that is needed to perform the method. Therefore to call this kind of method, you need to get (or create an instance of the class. Assuming the two methods are in the same class, you could do
    public class Foo
         public static void main(String[] args)
                Foo f = new Foo();
                f.callNonStaticMethod();
    }for instance.

Maybe you are looking for

  • How to transfer *some* media from one iTunes account to another?

    I have two iTunes libraries - one on my MacBook Air, and one on my external drive.  Why? Because I can't hold all of my TV shows and Movies on the MBA because of the small drive. What is the best way to move selected files between the two libraries -

  • How to Delete the configuration for Other comapny code in SAP system

    Hi, I am in deleteion of un-wanted company codes from Golden client. 1.I need to delete the profit centers, 2.but it is not accepting in that transaction code,it is giving the error. Error message: you can not delete the profit center.because profit

  • Moving Braodband

    Hi I am moving house soon to a new build property, the phone line is installed but I am not sure whether it is with BT or not. I work from home 2 days week and I need my broadband up and running as soon as possible. I need to know if any one has any

  • Not able to open forms After R12 installation

    Hi, I recently installed R12.0.4 on windows 2003 sp1. Post Installation tests were successful, and I am able to login with no issues. But when I try to open any form, no form is opening. Thanks, Raj ~ moving this to R12 Forum Edited by: CalvinNHobbes

  • The internet radio icon has vanished

    Have they dropped it? Is anyone else's missing? If not, how do I get it back? Already rebooted, no luck.