Referring to variables

If I have a class like this :
public class Thing
public Thing()
JLabel label = JLabel("label");
}How do I refer to the label from outside of the constructor method?
For instance if I make a Thing object in another class and want to change the label to "tree"

The variable must be a member variable if you want to access it from outside the constructor.
Example:public class Thing
    JLabel label;
    public Thing()
        label = JLabel("label");
}

Similar Messages

  • Refering a variable  value  whose name is stored in a string

    if the pgm is like this
    String abc= " marks";
    int marks = 65;
    using abc i want to refer the value of marks
    can any one help me ?

    Wow that sagely advise doesn't seem to be good at present:
    Google  Error  
    We're sorry...
    ... but we can't process your request right now. A computer virus or spyware application is sending us automated requests, and it appears that your computer or network has been infected.
    We'll restore your access as quickly as possible, so try again soon. In the meantime, you might want to run a virus checker or spyware remover to make sure that your computer is free of viruses and other spurious software.
    We apologize for the inconvenience, and hope we'll see you again on Google. :)

  • XI 3.0 File receive comm.channel using variable for folder/file name schema

    Hi,
    I prepared a integration message to produce .txt file output of message.
    I prepared message successfully, it's running properly and producing .txt file.
    My problem is to set .txt file name.
    I must set file name using by some information in .txt file.
    I must get some part of the first line of .txt to set filename.
    I declared a variable to do it.
    How can i set referance of variable?
    payload:..?
    Thanks.

    Hi,
    this blogs might be helpful:
    http://www.sdn.sap.com/irj/scn/weblogs;jsessionid=%28J2EE3417800%29ID0935780750DB11281184595516315205End?blog=/pub/wlg/13704
    http://www.sdn.sap.com/irj/scn/weblogs;jsessionid=%28J2EE3417800%29ID0935780750DB11281184595516315205End?blog=/pub/wlg/2664
    http://www.sdn.sap.com/irj/scn/weblogs;jsessionid=%28J2EE3417800%29ID0935780750DB11281184595516315205End?blog=/pub/wlg/1888
    http://wiki.sdn.sap.com/wiki/display/XI/CombiningthreedifferentaspectsofPIinoneshot
    Regards
    Patrick

  • Variable Selection Screen Options.....is this poss??

    Variable values can be displayed in Text, Text & Key, Key using the Hammer icon feature.
    How do I make say only " Text " ( for variables ) as default for all the users ?
    Message was edited by:
            Jr Roberto
    Message was edited by:
            Jr Roberto

    Ravi,
    I shud have mentioned that I was referring the variable selection screen which pops up when a query is run.
    Your idea works fine in my system but when I try under a diff a user its all the same again, Text is always defaulted!
    Is it possible to have Key Values Defaulted for  some variables & Text for some others??
    Any clue...
    Message was edited by:
            Jr Roberto

  • Use variable in mapping

    Hi!
    How to use Variable in mapping ? I've tried #PROJECT_CODE.VARIABLE_NAME but execution ends with an error "Illegal character"
    With regards,
    PsmakR

    There is no need to use package name if variable is locate in the same package with the interace. Else (according with documentation):
    Referring to variable MY_VAR in your objects should be done as follows:
    • #MY_VAR: With this syntax, the variable must be in the same project as the object referring to it. Its value will be substituted. To avoid ambiguity, consider using fully qualified syntax by prefixing the variable name with the project code.
    • #MY_PROJECT_CODE.MY_VAR: Using this syntax allows you to use variables across projects. It prevents ambiguity when 2 variables in different projects have the same name. The value of the variable will be substituted at runtime.
    • #GLOBAL.MY_VAR: This syntax allows you to refer to a global variable. Its value will be substituted in your code. Refer to section Global Objects for details.
    • Using “:” instead of “#”: You can use the variable as a SQL bind variable by prefixing it with a colon rather than a hash. However this syntax is subject to restrictions as it only applies to SQL DML statements.
    And make sure you declare it in the package as was suggested in the previous post.

  • OBIEE 11.1.1.6.2 BP1 Repository Variable data type

    I have some dynamic DATE variables created which fetches date values from a table. In the table the data type for that field is INTEGER.
    But on starting the server all date variables are initialized with .0d appended in the end. LIke 2012.0d etc.
    Kindly provide some pointers!
    Thanks
    KC
    Edited by: 959902 on Oct 30, 2012 8:26 AM

    Of Course we can do that.
    Your substring should not be in init block, it suppose to be where you are referring rep variable.
    In your prompt to set default values use sql query something like
    SELECT Time."Month" FROM "SA" WHERE Time."Year"=SUBSTRING(VALUEOF("PREVIOUS_MONTH") FROM 1 FOR 4)
    If helps pls mark ;)

  • How are variable stored?

    Hi,
    I'd like to know how variables are stored internally in the class file. Does Java uses an offset to refers to variable or something else? If it uses an offset it is possible to store "duplicated" variables (i.e., variables with the same name) keeping them separated, but in article of Gosling (I don't remember which) I read that Java tries to not use offsets. Can anybody explain me this?
    Luca

    Everything resolves down to references really !
    For local variables...
    A "frame" is created in the JVM, for every method being executed.
    Inside that frame is basically an array of "variable slots".
    The VM doesn't care about field names at this stage and just uses indexes.
    It's only at compile time that field names are considered.
    If you compile a class with debugging information, then then the compiler includes a "Local Variable Table". This is purely for debugging, not for the VM, and it maps field names to field positions.
    If you don't include debugging information, then it's not included... the VM doesn't care.
    For class field variables...
    The class file format is quite strict.
    No, you can't / shouldn't have duplicate class fields.
    The compiler has to resolve the references down to proper indices at compile time.
    regards,
    Owen

  • Input Field: Value Range in IP Web Layout

    Hi Experts,
    I've created a Web Layout based on IP with a copy function (e.g. from actual 2008 to plan2009) over 12 calendar months. For choosing the months to be copied, I created a Variable (calmonths) and added an Input Field into my layout to enter the the months to be copied. I referred the variable to the input field and it's working...
    When I want to select several months to be copied, I can type in " 1; 2; 3; " into the input field, execute the planning function and only month 1, 2, 3 (i.e. Jan, Feb, Mar) are being copied. But when I want to copy all 12 months, i have to enter 1; 2; 3; 4;...11; 12 which is kind of anoying! Has somebody some experience whether I can use a value range like 1-12 (or something like that) to avoid entering all the months individually? (I tried 1-12; 1- 12; 1 - 12; 1:12 etc but nothing like this is working)
    It would be very helpful if someone has an idea
    All the best,
    Norbert

    Hi Mayank, hi Srinivas.
    Thanks a lot for your valuable input! Unfortunately I was not able until today to test your recommodations.
    I tried your Interval variable but then faced the problem that I cannot enter multiple months anymore (e.g. 5 - 8 worked, 1; 3; 5 not).  Then I inserted both variables, multiple values & interval, into the planning function as well as in the button group in WAD for executing the PF but was not able to execute the following example: 1; 8; 4 - 6. After trying out for some time I figured out that one has to type in the figures in the following order: 4 - 6; 1; 8. Only then I am able to execute the planning function for the months April-June & Jan & August. So, if you're facing the same problem in the future, maybe you have the solution
    Best regards,
    Norbert

  • Can I use a for loop to add anonymous ActionListener objects?

    I have a setListener() method that has the following inside:
    for(int k = 0; k < buttons.length; k++)
        buttons[k].addActionListener(new ActionListener()
            public void actionPerformed(ActionEvent e)
                g2.setColor(colors[k]);
    }I have a JButton array and a Color array and I was hoping I could add them quickly in one shot rather than manually adding an anonymous ActionListener 9 times (I have 9 components). It tells me I need to make k final for an inner class and when I tested it by removing the for loop and keeping k as a final integer, it works. Is there a medium such that I can achieve what I want more or less while respecting Java's syntax?
    Any input would be greatly appreciated!
    Thanks in advance!

    s3a wrote:
    The local variable exists on the stack for as long as the method is executing. Once the method ends, that variable no longer exists. The newly created object, however, can continue to exist long after the method has ended. So when it's referring to variable X, it cannot refer to the same X as the one in the method, because that variable may no longer exist.Sorry for picking on little details but I am still not fully satisfied.
    Earlier I questioned if the local variable changed, but now let's say that that variable no longer exists at all, why does that even matter if the inner class copied the value and is keeping it for itself? What do you mean? The variable that existed in the method ceased to exist when the method ended. The inner class, however, can continue to live on, and can continue to refer to what we see as the same variable. However, it obviously can't be the same variable, since, in the world of the inner class, it still exists, while in the world of the method, it does not.
    This is completely independent of whether the variable changes or not. Regardless or whether the variable changes we still need two copies--one that goes away when the method's stack frame is popped, and one that lives on as long as the inner object does.
    Then, because there are two copies, the designers decided that the variable has to be final, so that they wouldn't have to mess with the complexity of keeping two variables in sync.
    That explanation leads me to believe that there is no copy and that there is some kind of "permanent umbilical cord" between the inner class and the local variable.Wrong. There has to be a copy. How else could the inner class keep referring to it after the method ends?
    Also, does marking it as final force it to be a permanent constant "variable" even if it's not a field "variable"? Or, similarly, does making a "variable" final make Java pretend that it is a field "variable"?Making a variable final does exactly one thing: It means the value can't change after it's been initialized. This is true of both fields and locals.
    As for the "pointless" byte-counting, I really don't see how it's confusing unless you're an absolute beginner. If I see somebody using a byte, I assume they have a real reason to do so, not pointless byte-hoarding. Then when I see that it's just a loop counter, I wonder WTF they were thinking, and have to spend some time determining if there's a valid reason, or if they're just writing bad code. Using a byte for a loop counter is bad code.
    I could then ask, why are people not using long instead of int and saying that that's using int is too meticulous?Part of it is probably historical. Part of it is because at 4 bytes, and int is exactly on word on the vast majority of hardware that Java has targeted since it came out. 8-byte words are becoming more common (64-bit hardware) but still in the minority.

  • Using Adapter-specific attributes in Mail adapter

    Hi,
    I try to use adapter-specific attributes in my Mail adapter. I set the "Use Adapter-Specific Message Attributes" indicator, but I do not get a result in the mapping and also in the SXMB_MONI the attributes are not visible.
    The documentation also refers to Variable Transport Binding indicator:<a href="http://help.sap.com/saphelp_nw04/helpdata/en/23/c093409c663228e10000000a1550b0/content.htm">http://help.sap.com/saphelp_nw04/helpdata/en/23/c093409c663228e10000000a1550b0/content.htm</a>
    Could this be the problem? I cannot find this indiciator! Does anyone know where I can find this indicator?
    Regards,
    Torsten

    Hi,
    The values for the parameters, set using adapter specific message attributes are available at runtime in the path http://sap.com/xi/XI/System/Mail.
    We need to write UDF's that can extract the values from this path.
    For Ex:
    DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters() .get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
    DynamicConfigurationKey key = DynamicConfigurationKey.create(
        “http://sap.com/xi/XI/System/File”,
        “FileName”);
    String valueOld = conf.get(key);
    if (valueOld != null) {
        String valueNew = valueOld.replaceAll(“input”,”output”);
        conf.put(key, valueNew);
    If you check Dynamic configuration in sxmb_moni, you would be able to find the values for all the attributes that have been set in the adapter.
    Regards,
    Smitha.

  • Receivables report - customer/transactions/receipt activities report

    is there any standard receivable report that can show all activities of transactions and receipts?
    something like the combination of 'applied receipt register' and 'unapplied receipt register'.
    or a statement of account that just show everything for a date range.. (which receipt applied to which invoices, which receipt still got balance, which invoices still got balances, which CN applied to which invoices, etc)

    Hi,
    The variables for the 2005 version are in general not supported (SAP Note 723783).
    For the 2005A version there is not list.
    Now in the new 2007A there a detailed list refering which variable are available for the documents.
    https://websmp110.sap-ag.de/~sapidb/011000358700000491342007E.zip
    Check if you can find something helpful in the document.
    Regards,
    Jitin

  • Functions from Module Scoping Question

    Hello,
    I have the following case:
    I`m using module that contains several functions, some of them are executing commends in remote sessions. These functions are used from Powershell Script.
    The issue is that when function refers to variable from the local computer using the “$Using:var” syntax, it does not tries to access the variables that is defined in Script scope.
    The exception is:
    “Invoke-Command : The value of the using variable ‘$using:var’ cannot be retrieved because it has not been set in the local session.”
    This behavior is not reproduced when the functions are defined in the Script. I`m aware that Modules have their own “Scope”(or Context or whatever…), so I suppose the behavior is by design
    I`m able to workaround it in two ways:
    Using the “$Using:global:var” syntax in the script block or dot source the script.
    However it`s not so appropriate for my purpose.
    My Question is:
    Can I force the Functions that comes from Module to behave the same way as if they are defined in the Script.
    Any other suggestions are welcome.
    Some examples:
    Module content:
    function Main
    param
    $sb2
    $ses = New-PSSession -ComputerName sof-srv01
    Execute -ses $ses -sb $sb2
    function Execute
    param (
    $sb,
    $ses
    Invoke-Command -Session $ses -ScriptBlock $sb
    Export-ModuleMember Execute,Main
    Script content:
    $var = ‘winrm’
    $scr = {Get-Service $using:var}
    Main -sb2 $scr

    You're wrong as always: there's such a thing as DOT SOURCING MODE when using Import-Module.
    Finally, you must know by now, that your post above is plain RUBBISH. 
    In other words, you are a complete PowerShell ignorant ( probably, you are a good rubbishellian ). 
    Surely, you re-read your BUGGY bug report https://connect.microsoft.com/PowerShell/feedback/details/828782/functions-in-script-modules-do-not-inherit-variables-from-the-scope-of-their-caller.
    Now, someone posted how-to-do-it ...
    I have no idea WHERE and WHY you got these three letters: m, v and p...
    P.S.: How do you dare to post your rubbishell concepts in my reports? Leave my posts
    clean!
    Well, at least you finally had the guts to post what you meant by "Import-Module in DOT SOURCING MODE".  As expected, it's garbage.
    As you've pointed out, when you pass a path to a .ps1 file to Import-Module, it recognizes that a .ps1 file is not a module, and just dot-sources the script to load its contents instead.  (And as you pointed out in your report on connect, this behavior
    is buggy.  Microsoft probably shouldn't have included it at all, and just had Import-Module produce an error if you try to point it as a non-module file, but whatever.  The functionality is there now.)
    Any discussion of Script Modules has nothing do with dot-sourcing a ps1 file, regardless of whether you did it yourself, or called Import-Module.  Script Modules are psm1 files, and when they are imported, it happens in a very different way than when
    a script is dot-sourced.  Modules get their own session state which is separate from the main PowerShell session (except for the Global scope, which is shared by everything).  That separation of session state is what leads to the types
    of problems the OP posted here.
    Now that you've finally owned up to what you were talking about, it would appear that your proposed solution is to stop using Script Modules, and just dot-source ps1 files instead.  Have fun with that.

  • Query in RSRT Transaction

    Hi,
    I have a requirement in which i am creating an enhancement implementation . In this i am selecting the data for a field from a table /BIC/MC_SSPHASE, based on the input (selection field in the query say X) in RSRT transaction. Can anyone help me to know  - how to retrieve the data of that selection field -X  from Tranaction RSRT into my enhancement implementation  ?
    In that implementation we have a method - this method have the parameters as:
    i_vnam
    i_vartyp
    i_iobjnm
    i_s_cob_pro
    i_s_rkb1d
    i_periv
    i_t_var_range
    i_step
    r_t_range
    e_meeht
    e_mefac
    e_waers
    In which parameter - i can found the value and fthe fields of the selection screen of RSRT transaction?
    Thanks .
    Edited by: SAP_Kaur on Feb 16, 2012 8:12 AM

    Hi,
    Not sure, but you can check the parameter i_t_var_range for getting the selection value of variable. Because this table is referred in Variable customer exit to read the values of other variable  input given on selection screen.
    Regards,
    Durgesh.

  • How to do a select from a table whose name is saved in a field?

    Hello,
    This is an abap report.
    I need to do a select from a table whose name is saved in a field of Z* table.
    Like this..
    SELECT * FROM znodos.
       SELECT * FROM znodos-tabla.   "znodos-tabla contain the Z* table name
           move zodos-tabla-txtmd to.....
       endselect.
    endselect.
    Is this possible??
    Thanks

    Hi Ilie Aleman 
    Give variable name in ().. Variable name refers to variable which contains table name
    SELECT * FROM (znodos-tabla).
    Regards,
    Mohaiyuddin
    Edited by: Mohaiyuddin Soniwala on Jan 22, 2008 5:18 PM

  • Prefix timestamp before the name of the file

    Hi Experts,
    Can we prefix timestamp before the name of the file?
    Generally file name followed by timestapm instead of that
    can we add timestamp before file name? .If so please let me know .
    thanks in advance
    N.P.Babu

    Hi,
    all you need to do it to create the filename
    in one of the tag in your xml message and
    then use variable substitution:
    refere to Variable Substitution section on this page
    http://help.sap.com/saphelp_nw04/helpdata/en/bc/bb79d6061007419a081e58cbeaaf28/content.htm
    it's easy but using
    Adapter-Specific Message Attributes
    with sp14 is much better
    Regards,
    michal

Maybe you are looking for

  • HT4858 how do i copy photos from iCloud to my personal drive?

    how do i copy photos from iCloud to my personal drive?

  • Making adjustments to still images in PS crashes FCE

    When I drop still pictures into my project (tiffs), sometimes they need a little tweaking back in Photoshop to look just right. So, I hold down the control key and click on the clip, and in the box that pops up I choose Open In Editor. That opens the

  • Import Que not working properly

    Hi All, We have a situation : We have upgraded the OS in our DEV server from Win 2000 to Win 2K3. For carrying out this we have restored the last offline backup of the DEV system. But after configuring the TMS in all system we are facing a problem, t

  • Custom Apex theme prohobits CSV Download link

    Hi, I'm using Apex 3.2.1.00.12; Database version = 11.1.0.7.0. A customized theme is used for the application. For a reports region I added CSV Download link, but it is not showing when i run the page. Please let me know if any settings to be changed

  • Change Data Capture option in v$option

    Hi when i run the following query : select parameter, value from v$option i notice that the change data capture is FALSE, does it mean that i can't use the change data capture. i want to make you know that we use an ORACLE 10gR2 standard edition. Bes