Passing objects into a class constructor

I've created a frame for inputting a patient's medical results. There are lots of buttons for temperature, blood pressure, etc. I've created a separate, inner class that creates a NumberPad frame to enter the patient's results. Press the "Temp." button, for example, a NumberPad appears, you enter the temperature, press the "Enter" button on the NumberPad and the number appears in a Label next to the "Temp." button.
The problem is that I've written the constructor of the NumberPad with a label parameter so that the right label gets updated. e.g.
class NumberPad extends Frame implements ActionListener
public NumberPad(Label aLabel)
However, because I've implemented ActionListener, I've had to override the actionPerformed method and I don't know how to pass the aLabel object that I give to the NumberPad constructor into the actionPerformed method so that, for example
public actionPerformed(ActionEvent evt)
String s = evt.getActionCommand
if (s.equals("ENTER")
aLabel.setText(display of numberpad);
How do I transfer the aLabel object into the actionPerformed method so that the correct label gets updated?

Store the label as an instance variable.
class NumberPad extends Frame implements ActionListener {
    private Label aLabel;
    public NumberPad(Label aLabel) {
        this.aLabel = aLabel;
    public actionPerformed(ActionEvent evt) {
        String s = evt.getActionCommand;
        if (s.equals("ENTER") {
            aLabel.setText(display of numberpad);
}[/code}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

Similar Messages

  • Unable to Cast a Object into Typed Class

    Hi, I am not able to cast a simple object in typed class.
    I have a class ItemVO.as
    package
        public class ItemVO
            public var idData:String;
            public var valData:String;
    In application on some action
                var obj:Object = new Object;
                obj['idData']="001";
                obj['valData']="abhinav";
                try{
                    var itemVO:ItemVO=ItemVO(obj);
                }catch(e:Error)
                    Alert.show(e.message);
    I am getting below error at var itemVO:ItemVO=ItemVO(obj)
    Error #1034: Type Coercion failed: cannot convert Object@b5c3ad9 to ItemVO.
    Where I am doing wrong??
    Please help.
    Thanks.
    Abhinav

    You need to do it by hand.
    Or make ItemVO able to take an object as constructor argument. Which is again doing it by hand.
    public function ItemVO(obj:Object)
        idData = obj.idData;
        valData = obj.valData;
    C

  • How do I pass objects into EL so they can be printed with c:out ?

    Hi, I have an already made jsp and it contains data that is printed with <c:out>
    <c:out value="${model.biz.address.city}" />Now I would like to make changes to the page, but still use these object names. I'm pretty new to java, so I just assumed to make classes: a big class for model with basic fields; a secondary class for biz, containing name, description, etc in public fields; and an address class, which holds the city, state, etc variables.
    I have tomcat/jstl. On the server, there is all this database code and etc that will provide the information, but as for me, I would like to make a simple page, that will have just one model with all the information filled in, so that, I can use the ${model.biz.address.city} or ${model.biz.name} or whatever information objects I've provided.
    I can access my classes with <% out.println(model.biz.name) %>, but I can't access it with EL. How can I do it?
    I mind you there is nested information: model has model.biz & model.user; biz has biz.name, biz.phone, biz.email, and biz.address; biz.address has address.address1, address.address2, and address.city, etc.
    ANY help will be greatly appreciated! Thanks!

    Geez .. Your class doesn't fulfill the javabean specifications. The properties should not be public.
    It should rather look likepublic class TheAddress {
        // Properties ---------------------------------------------------------------------------------
        private String address1;
        private String address2;
        // Constructors -------------------------------------------------------------------------------
        public TheAddress() {
            // Default constructor.
        public TheAddress(String address1, String address2) {
            // Full constructor.
            this.address1 = address1;
            this.address2 = address2;
        // Getters ------------------------------------------------------------------------------------
        public String getAddress1() {
            return address1;
        public String getAddress2() {
            return address2;
        // Setters ------------------------------------------------------------------------------------
        public void setAddress1(String address1) {
            this.address1 = address1;
        public void setAddress2(String address2) {
            this.address2 = address2;
    }

  • Passing object into form

    I have a workflow where I check out a configuration object and I need to pass it to a form for updating, then check it back in at the workflow level. Does anyone have a snippet of code where they have successfully passed the object to the form and back again? I know I'm getting the components of the object correctly, it's just not passing up to the form.
    Thanks in advance for any help.
    -T-

    Now I'm getting " com.waveset.util.WavesetException: Suspended case with no WorkItems!"
    Here is the workflow minus start and end: (Remember, the object displays fine on the form)
    <Activity id='1' name='Checkout Object'>
    <Action id='0' application='com.waveset.session.WorkflowServices'>
    <Argument name='op' value='checkoutObject'/>
    <Argument name='type' value='Configuration'/>
    <Argument name='name' value='ADServerLookupTable'/>
    <Argument name='authorized' value='true'/>
    <Variable name='object'/>
    <Return from='object' to='ADobject'/>
    </Action>
    <Transition to='Show Form'/>
    <WorkflowEditor x='215' y='59'/>
    </Activity>
    <Activity id='2' name='Show Form'>
    <Action id='0' name='Clear Form Button'>
    <expression>
    <set name='formButton'>
    <null/>
    </set>
    </expression>
    </Action>
    <ManualAction id='1' name='Show ADconfigMgmt Form' syncExec='true'>
    <Owner name='$(WF_CASE_OWNER)'/>
    <FormRef>
    <ObjectRef type='UserForm' id='#ID#UserForm:ADconfigMgmt' name=' UserForm AD Configuration Mgmt'/>
    </FormRef>
    <Return from='ADobject' to='ADobject'/>
    <ExposedVariables>
    <List>
    <String>ADobject</String>
    </List>
    </ExposedVariables>
    <EditableVariables>
    <List>
    <String>ADobject</String>
    </List>
    </EditableVariables>
    </ManualAction>
    <Transition to='Checkin Object'>
    <eq>
    <ref>formButton</ref>
    <s>Save</s>
    </eq>
    </Transition>
    <Transition to='Unlock Object'>
    <eq>
    <ref>formButton</ref>
    <s>Cancel</s>
    </eq>
    </Transition>
    <Transition to='Unlock Object'>
    <ref>WF_ACTION_TIMEOUT</ref>
    </Transition>
    <WorkflowEditor x='301' y='59'/>
    </Activity>
    <Activity id='3' name='Checkin Object'>
    <Action id='0' application='com.waveset.session.WorkflowServices'>
    <Argument name='op' value='checkinObject'/>
    <Argument name='object' value='$(ADobject)'/>
    <Argument name='authorized' value='true'/>
    </Action>
    <Transition to='end'/>
    <WorkflowEditor x='59' y='10'/>
    </Activity>
    <Activity id='4' name='Unlock Object'>
    <Action id='0' application='com.waveset.session.WorkflowServices'>
    <Argument name='op' value='unlockObject'/>
    <Argument name='object' value='$(ADobject)'/>
    <Argument name='authorized' value='true'/>
    </Action>
    <Transition to='end'/>
    </Activity>
    Edited by: TD_ROC on May 6, 2008 12:03 PM

  • Putting a Class Object into a Vector

    HI all
    I need to put a class object into another classes vector, then be able to read it and retrieve data.
    I can put the object into the vector but all i seem to be able to retrieve is data like Account@2343c2.
    Is this some sort of tag? How do i get to the data?
    thankz
    joey

    That's what you get when you print an object which does not have its own toString() method to do anything different - it picks up the Object class's toString method instead. For example:
    System.out.println(new Object());It sounds like you're doing something like this:
    Vector v = new Vector();
    v.add(new Account(42));If you were to do the following, you would see that sort of output:
    System.out.println(v.get(0));The appropriate way to do this would be something like the following:
       // Use a List reference instead of a Vector reference, and create
       // an ArrayList object in preference to a Vector object
       List list = new ArrayList();
       list.add(new Account(42));
       // Iterate through the list of accounts - use an
       // iterator because this prevents off-by-one errors
       // that arise with direct indexing.
       Iterator i = list.iterator();
       while(i.hasNext()) {
          // Cast the reference returned by the iterator from
          // Object to Account so that we can call account-specific
          // methods.
          Account current = (Account)i.next();
          // Call the method specific to the Account class (getBalance
          // is just an example that I made up).
          System.out.println(current.getBalance());
       }

  • How to pass the object of one class to the another class?

    Hello All,
    My problem is i am sending the object of serializable class from one class to another class but when i collection this class into another it is transfering null to that side even i filled that object into the class before transfer and the point is class is serializable
    code is below like
    one class contain the code where i collecting the object by calling this function of another class:-
    class
    lastindex and initIndex is starting and ending range
    SentenceStatusImpl tempSS[] = new SentenceStatusImpl[lastIndex-initIndex ];
    tempSS[i++] = engineLocal.CallParser(SS[initIndex],g_strUserName,g_strlanguage,g_strDomain);
    another class containg code where we transfering the object:-
    class
    public SentenceStatusImpl CallParser(SentenceStatusImpl senStatus, String strUserName, String strLanguage, String strDomain)
    *//here some code in try block*
    finally
    System.+out+.println("inside finally...........block......"+strfinaloutput.length);
    senStatus.setOutputSen(strfinaloutput);//strfinaloutput is stringbuffer array containg sentence
    fillSynonymMap(senStatus);
    senStatus.setTranslateStatus(*true*);
    return senStatus;
    Class of which object is serialized name sentenceStatusimpl class:-
    public class SentenceStatusImpl implements Serializable
    ///Added by pavan on 10/06/2008
    int strSourceSenNo;
    String strSourceSen = new String();
    String strTargetSen = new String();
    StringBuffer[] stroutputSen = null;
    HashMap senHashMap = new HashMap();
    HashMap dfaMarkedMap = new HashMap();
    boolean bTargetStatus = false;
    public SentenceStatusImpl(){
    public void setOutputSen(StringBuffer[] outputSen){
    stroutputSen = outputSen;
    public StringBuffer[] getOutputSen(){
    return stroutputSen;
    public void setTranslateStatus(*boolean* TargetStatus){
    bTargetStatus = TargetStatus;
    }//class

    ok,
    in class one
    we are calling one function (name callParser(object of sentenceStatusImpl class,.....argument.) it return object of sentenceStatusImple class containg some extra information ) and we collecting that object into same type of object.
    and that sentenceStatusImple classs implements by Serializable
    so it some cases it is returning null
    if you think it is not proper serialization is please replay me and suggest proper serialization so that my work is to be done properly (without NULL)
    hope you understand my problem

  • How do u pass an object into a method

    I want to create a method getData that takes an object of type Helper and returns an object of the same type.
    how do u pass objects into a method and how do u get objects as returns im a bit confused

    That will just allow you to pass a parameter. If you want to return a helper object
    Helper paramHelper = new Helper();
    Helper someHelper = callMethod(paramHelper);
    public Helper callMethod(Helper hobj) {
        //<some code>
        Helper retHelper = new Helper();
        //<blah, blah>
        return retHelper;

  • How to pass a locale object into another function?

    Greetings,
    i like to pass a locale object into another function. These are my code below
    import java.util.*;
    public class Locales{
         public static void main(String[] args){
              Locale locale= new Locale("EN", "US");
              convert(locale);
    public void convert(Locale convert)
         String language = convert.getDisplayLanguage();
         System.out.println(language);          
    }I got this error:
    Locales.java:6: non-static method convert(java.util.Locale) cannot be referenced from a static content
                    convert(locale);
                    ^How do i correct it?
    Thanks

    Did you bother to do a search?
    Did you bother to read any of the material that the search would have linked you to?
    If you had then you would be able to understand where you are going wrong and how to fix it yourself. Instead of being spoonfed by us.

  • Passing an object into a tag

    Hello
    I have a tag file called foo.tag
    <%@tag description="some tag" pageEncoding="UTF-8"%>
    <%@tag import="java.util.*"%>
    <%@attribute name="list" type="java.util.List" required="true"%>
    <h4>I am a list</h4>
    <p>Class: <%=list.getClass()%></p>And in my index.jsp I do:
    <%@ taglib prefix="jc" tagdir="/WEB-INF/tags" %>
    <%
          List bar = new ArrayList();
          bar.add("test");
    %>
    <jc:foo list="<%=bar%>"/>..in order to pass the reference of bar in my tag. That works, but I know that it's "bad" practice to have <%= %> inside your JSPs. How could I improve the parameter passing? If I say <jc:foo list="bar"/> then I only get a "bar" String on the tag file.
    thanks

    Thanks for your reply.
    But is there a better way of doing this? Yeah, there is a slightly better way if you are using JSP 2.0 (properly configured). Then you can do:
    <% List bar = new ArrayList();
       bar.add("foo");
       request.setAttribute("bar", bar);
    %>
    <jc:foo list="${bar}"/>
        public void setList(List theList) { ... }
    Can't I just
    feed the object into the tag as an object?Not directly. The List you create in the scriptlet has a limited scope, just inside the _jspService method.  This scope isn't really available to things like tags and EL, so you have to put it in a scope where it can be found - something like the request, or page scopes.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Class Object into Byte Array

    Is there a way to copy a class object into a byte array? If so, how?

    hi check out
    http://forum.java.sun.com/thread.jspa?threadID=562268&
    messageID=2766098This does not work in j2me. WriteObject does not exist, and there are no serialsation interfaces in j2me. So you'll have to do that on your own.
    look here: http://java.sun.com/developer/J2METechTips/2002/tt0226.html

  • Invoked super class constructor means create an object of it?

    Hei,
    i have create one class that extends another class. when i am creating an object of sub class it invoked the constructor of the super class. thats okay.
    but my question is :
    constructor is invoked when class is intitiated means when we create an
    object of sub class it automatically create an object of super class. so means every time it create super class object.

    Hi,
       An object has the fields of its own class plus all fields of its parent class, grandparent class, all the way up to the root class Object. It's necessary to initialize all fields, therefore all constructors must be called! The Java compiler automatically inserts the necessary constructor calls in the process of constructor chaining, or you can do it explicitly.
       The Java compiler inserts a call to the parent constructor (super) if you don't have a constructor call as the first statement of you constructor.
    Normally, you won't need to call the constructor for your parent class because it's automatically generated, but there are two cases where this is necessary.
       1. You want to call a parent constructor which has parameters (the automatically generated super constructor call has no parameters).
       2. There is no parameterless parent constructor because only constructors with parameters are defined in the parent class.
       I hope your query is resolved. If not please let me know.
    Thanks & Regards,
    Charan.

  • How to pass any type of objects into Portal's rules engine?

    Is that possible to pass any type of objects into Portal's rules engine? Or BEA's Portal service rules engine can only allow to pass a limited number of objects?
    Are there any information about BEA's rules engine? and Can we use its rules engine without using its Portal service?
    Thank you.

    I worked on BEA rules engine 4 months back. I'm sure you can pass any JAVA object to it's working meomory. I am giving my sample rules here, hope it will be helpful for you.
    I just replace pcakage name, other than that everything is from wroking project. Open in xml spy, it should be clear from the desc. If you have any questions post back.
    <cr:rule-set is-complete="true" xmlns="http://www.bea.com/servers/p13n/xsd/expression/expressions/2.1.1" xmlns:cr="http://www.bea.com/servers/p13n/xsd/rules/core/2.1.1" xmlns:literal="http://www.bea.com/servers/p13n/xsd/expression/literal/1.0.1" xmlns:string="http://www.bea.com/servers/p13n/xsd/expression/string/1.0.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.bea.com/servers/p13n/xsd/rules/core/2.1.1 rules-core-2_1_1.xsd">
         <cr:rule is-complete="true">
              <cr:name>TaxForm1040</cr:name>
              <cr:description>If salary is 70,000 then this rule makes 1040 as required form</cr:description>
              <cr:conditions>
                   <multi-and>
                        <multi-and>
                             <equal-to>
    <instance-method>
    <variable>
    <name>SalaryField</name>
    <type-alias>com.blah.field.REInputObject</type-alias>
    </variable>
    <name>getKey</name>
    </instance-method>
    <literal:string>Salary</literal:string>
    </equal-to>
    <equal-to>
    <instance-method>
    <variable>
    <name>SalaryField</name>
    <type-alias>com.blah.field.REInputObject</type-alias>
    </variable>
    <name>getValue</name>
    </instance-method>
    <literal:integer>70000</literal:integer>
    </equal-to>
                        </multi-and>
                   </multi-and>
              </cr:conditions>
              <cr:actions>
                   <new-instance>
                        <type-alias>com.blah.field.RequiredField</type-alias>
                        <arguments>
                             <literal:string>1040</literal:string>
                        </arguments>
                   </new-instance>
              </cr:actions>
         </cr:rule>
    </cr:rule-set>

  • Project PSI API checkoutproject is causing exception :LastError=CICOCheckedOutToOtherUser Instructions: Pass this into PSClientError constructor to access all error information

    Hi,
    I'm trying to add a value to the project custom field. After that I'm calling the checkout function before the queueupdate and queuepublish. While calling the checkout  the program is throwing exception as follow:
    The exception is as follows: ProjectServerError(s) LastError=CICOCheckedOutToOtherUser Instructions: Pass this into PSClientError constructor to access all error information
    Please help me to resolve this issue.  I have also tried the ReaProjectentity method i nthe PSI service inrodr to find that project is checked out or not  . Still  the issue is remains . Anyone please help me for this
    flagCheckout = IsProjectCheckedOut(myProjectId);
                        if (!flagCheckout)
                            eventLog.WriteEntry("Inside the updatedata== true and value of the checkout is " + flagCheckout);
                            projectClient.CheckOutProject(myProjectId, sessionId, "custom field update checkout");
    Regards,
    Sabitha

    Standard Information:PSI Entry Point:
    Project User: Service account
    Correlation Id: 7ded1694-35d9-487d-bc1b-c2e8557a2170
    PWA Site URL: httpservername.name/PWA
    SSP Name: Project Server Service Application
    PSError: GeneralQueueCorrelationBlocked (26005)
    Operation could not completed since the Queue Correlated Job Group is blocked. Correlated Job Group ID is: a9dda7f4-fc78-4b6f-ace6-13dddcf784c5. The job ID of the affected job is: 7768f60d-5fe8-4184-b80d-cbab271e38e1. The job type of the affected job is:
    ProjectCheckIn. You can recover from the situation by unblocking or cancelling the blocked job. To do that, go to PWA, navigate to 'Server Settings -> Manage Queue Jobs', go to 'Filter Type' section, choose 'By ID', enter the 'Job Group ID' mentioned in
    this error and click the 'Refresh Status' button at the bottom of the page. In the resulting set of jobs, click on the 'Error' column link to see more details about why the job has failed and blocked the Correlated Job Group. For more troubleshooting you can
    look at the trace log also. Once you have corrected the cause of the error, select the affected job and click on the 'Retry Jobs' or 'Cancel Jobs' button at the bottom of the page.
    This is the error I'm getting now while currently calling the forcehckin, checkout and update. Earlier it was not logging any errors.From this I'm not able to resolve as i cannot filter with job guid

  • JRC with JavaBeans datasrc - how to pass params into javabean.getResultSet?

    Hi.
    I'm developing javabeans data sources for crystal reports for the java/JRC engine.  I've seen the document entitled Javabeans Connectivity for Crystal.  It TALKS ABOUT passing params into the methods that return java.sql.ResultSets but there is absolutely no example code anywhere that I can find on how to do it.
    What I don't understand is:  Since the JRC engine is basically controlling the instantiation of the javabean, other than calling some type of fetch method in the constructor, how the heck am I supposed to pass in db connection info and a sql string? 
    Anybody got sample code for how to call/where to call parameters that I would put in a custom getResultSet method??
    Thanks.

    I don't think that a Connection Pool class would be an ideal candidate for becoming a JavaBean. One of the most prevalent use of a JavaBean class it to use it as a data object to collect data from your presentation layer (viz. HTML form) and transfer it to your business layer. If the request parameter names match the Bean's property names, a bean can automatically get these values and initialize itself even though it has a zero argument ctor. Then a Bean could call methods in the business layer to do some processing, to persist itself etc.

  • No Pass-by-Value or Copy Constructors

    After having used AS3 for some months now, I've realized that
    there is no pass-by-value option when passing variables into
    functions. The only option is pass-by-reference. Similarly, there
    are no default copy constructors. So, if I want to create a copy of
    an object, I have to write code to create a new instance of the
    object and manually copy all of the source variable's properties to
    the new target object.
    This lack of a pass-by-value mechanism and copy constructors
    leads to some confusing behavior and necessitates writing quite a
    bit of extra code. A common case involving confusion is when a
    function call changes a property of a passed-in object. The caller
    might assume that the object will not be modified and then be
    surprised when it is. This is especially likely to happen when
    different people are working on the caller and the callee. It
    shouldn't be necessary for the caller to be concerned about the
    internal workings of an object being used but, because there is no
    pass-by-value mechanism, the caller often must take this into
    account.
    Because of the lack of a pass-by-value mechanism the onus is
    on the person writing a function to always make a copy of passed-in
    objects if they are going to be modified. Unfortunately, the lack
    of default copy constructors makes this an onerous task. The only
    way to copy an object is to write code to create a new object and
    then copy each property of the object. Where the properties are
    objects themselves a deep copy is needed and the amount of code can
    become large and the task tedious. To do this amounts to writing a
    set of copy constructors for each object and sub-object - each time
    a variable is accessed for modify.
    To make matters worse, it's not even possible to write a copy
    constructor for user-created classes. Consider the following
    attempt at writing a copy constructor to copy two instance
    variables for a custom Form class:
    public function Form(f:Form) {
    this._textHeight = f._textHeight;
    this._actionURL = f._actionURL;
    This causes a "Duplicate function definition" compile error
    because a default constructor already exists.
    Pass-by-value and built-in copy constructors are standard
    features in most OOP languages and their lack in AS3 is a glaring
    omission. I hope Adobe will seriously consider adding them to the
    next version of ActionScript.

    Nitin_Mathur wrote:
    at one time i had doubted my own conceptsNote that the type of a parameter may be different from the type of the object you created. However, it is still the same value that is passed, as pointed out by this example:
    public class Test {
        public Test() {
            //an object of type "MyClass" is created on the heap with the "new" operator:
            MyClass myClass = new MyClass();
            doSomething(myClass);//the reference to the object is passed by value
        private void doSomething(MyInterface myInterface) {
            //the passed value is a reference to a "MyClass" object,
            //but here it is considered to be a "MyInterface" object
            //and we don't have access to the "MyClass"-method "testClass()"
            myInterface.testInterface();
        public static void main(String[] args) {
            new Test();
    interface MyInterface {
        public void testInterface();
    class MyClass implements MyInterface {
        public void testInterface() {
            System.out.println("testInterface");
        public void testClass(){
            System.out.println("testClass");
    }

Maybe you are looking for

  • Is there a way to recover my iTunes gift card code w/out the card?

        It has been a couple weeks since I have last made a purchase on iTunes, and for some reason it decided to stop using the remaining balance on my giftcard when I recently tried to make a purchase. It shows that I do indeed have a balance left but

  • Unable to find infosource

    Hi Gurus, I am trying to create 3.x infosource to posting period info object (unassigned category). when i try to create infosource for 0fiscper3 in 3.x it was initially successfull. but i am not able to find it in my infosource tree. when i tried to

  • Memory problem - state saving?

    Hi, We've been having some serious memory leak problems with our application, and is seems like we've narrowed down the symptoms : Objects referenced by af:table components (i.e. The classes that the rows of the table are based on) continually have t

  • Website sound not coming thru iPod Touch - Is there a solution???

    Hello all, I have the iPod Touch and when connecting to the internet with it, to a site such as Sirius.com to listen to music or talk, no audio comes thru. For instance, if I want to log into my sirius.com account, and listen to a talk show, how do I

  • Implementing Nakisa on HCM system

    Hi All, We have ERP EHP4 (HCM) and poral EHP1) systems in our landscape. Now our plan is to implement Talent Management with Trex and Nakisa. As this is a new activity for me kindly help in planning out the Implimentation of Talent Management in our