How to access class variables in anonymous class??.

I have a boolean class level variable. Fom a button action , this boolean will set to true and then it used in anonymous class. In anonymous class, I am getting default value instead of true. Could u anyone help in this plzzz.

first of all, you don't want parent because that is something that Containers use to remember their containment hierarchy. you are thinking of super which is also incorrect, because that has to do with inheritance.
the problem here is a scoping problem. you generally would use final if you were accessing variables in an anonymous class that are in the local scope. in this case, you just need to create some test code and play with it. snip the code below and play with it. it shows both the given examples and some additional ways to change/display class variables.
good luck, hackerx
import javax.swing.*;
import java.awt.event.*;
public class Foo extends JPanel
     private boolean the_b = true;
     public static void main(String[] args)
          Foo f = new Foo();
          JFrame frame = new JFrame();
          frame.getContentPane().add(f);
          frame.pack();
          frame.show();
     public Foo()
          // get your button
          JButton b = new JButton("Not!");
          b.addActionListener(new ActionListener()
               public void actionPerformed(ActionEvent ae)
                    // *** uncomment these to play around ***
                    // Foo.this.the_b = false; // this will work, but unnecessary
                    // the_b = false; // this works fine too
                    notFoo();
          this.add(b);
          // something to show the value that accesses a class variable
          // using an inner class instead of final nonsense
          DisplayThread t = new DisplayThread();
          t.start();
     private void notFoo()
          the_b = !the_b;
     class DisplayThread extends Thread
          public void run()
               while(true)
                    System.err.println("boolean value: " + the_b);
                    try {
                    sleep(1000);
                    } catch(InterruptedException ie) {}
}

Similar Messages

  • [svn] 4492: Simplified how an accessibility class gets hooked into its corresponding component class .

    Revision: 4492
    Author: [email protected]
    Date: 2009-01-12 14:47:10 -0800 (Mon, 12 Jan 2009)
    Log Message:
    Simplified how an accessibility class gets hooked into its corresponding component class.
    We now do the hooking in the static method enableAccessibility(), which is called by code that is autogenerated by the compiler. Previously this method did nothing and the hooking happened at static initialization time. This allows us to remove the static var accessibilityHooked and the static method hookAccessibility() in each accessibility class.
    QE Notes: None
    Doc Notes: None
    Bugs: None
    Reviewer: Deepa and Alex
    Modified Paths:
    flex/sdk/trunk/frameworks/projects/framework/src/mx/accessibility/AccImpl.as
    flex/sdk/trunk/frameworks/projects/framework/src/mx/accessibility/AccordionHeaderAccImpl. as
    flex/sdk/trunk/frameworks/projects/framework/src/mx/accessibility/AlertAccImpl.as
    flex/sdk/trunk/frameworks/projects/framework/src/mx/accessibility/ButtonAccImpl.as
    flex/sdk/trunk/frameworks/projects/framework/src/mx/accessibility/CheckBoxAccImpl.as
    flex/sdk/trunk/frameworks/projects/framework/src/mx/accessibility/ColorPickerAccImpl.as
    flex/sdk/trunk/frameworks/projects/framework/src/mx/accessibility/ComboBaseAccImpl.as
    flex/sdk/trunk/frameworks/projects/framework/src/mx/accessibility/ComboBoxAccImpl.as
    flex/sdk/trunk/frameworks/projects/framework/src/mx/accessibility/DataGridAccImpl.as
    flex/sdk/trunk/frameworks/projects/framework/src/mx/accessibility/DateChooserAccImpl.as
    flex/sdk/trunk/frameworks/projects/framework/src/mx/accessibility/DateFieldAccImpl.as
    flex/sdk/trunk/frameworks/projects/framework/src/mx/accessibility/LinkButtonAccImpl.as
    flex/sdk/trunk/frameworks/projects/framework/src/mx/accessibility/ListAccImpl.as
    flex/sdk/trunk/frameworks/projects/framework/src/mx/accessibility/ListBaseAccImpl.as
    flex/sdk/trunk/frameworks/projects/framework/src/mx/accessibility/MenuAccImpl.as
    flex/sdk/trunk/frameworks/projects/framework/src/mx/accessibility/MenuBarAccImpl.as
    flex/sdk/trunk/frameworks/projects/framework/src/mx/accessibility/PanelAccImpl.as
    flex/sdk/trunk/frameworks/projects/framework/src/mx/accessibility/RadioButtonAccImpl.as
    flex/sdk/trunk/frameworks/projects/framework/src/mx/accessibility/SliderAccImpl.as
    flex/sdk/trunk/frameworks/projects/framework/src/mx/accessibility/TabBarAccImpl.as
    flex/sdk/trunk/frameworks/projects/framework/src/mx/accessibility/TitleWindowAccImpl.as
    flex/sdk/trunk/frameworks/projects/framework/src/mx/accessibility/TreeAccImpl.as
    flex/sdk/trunk/frameworks/projects/framework/src/mx/accessibility/UIComponentAccProps.as

    Was it really necessary to post the whole API description?!?
    Locale[] locales = Locale.ENGLISH();ENGLISH is not a method in class Locale, so do not add the braces "( );".
    Also, the constant ENGLISH is not an array, but just a single Locale object.
    You didn't say what your problem was. What do you want to achieve with your program and what is it that you don't understand?

  • How to access system variables in Script Component in data flow task in SSIS

    Hi,
    I am new to SSIS. Can someone tell me how to access system variable in Script Component in SSIS using C# code.
    Thanks

    You can use the System.Environment.GetEnvironmentVariable(...) to read the variables. An example is here:
    http://msdn.microsoft.com/en-us/library/y6k3c7b0.aspx
    Vikash Kumar Singh || www.singhvikash.in

  • How to access _global variables in different domain

    hi
    i am loading a swf in local and this has to be communicate the swf which was in the server(different domain). using the system.security.allowdomail i can access the variables, but i can't able to access _global variable.
    Pls tell how to access _global variable in different domain
    Thanks in advance
    @flash

    Ganesh,
    It should work the way you mentioned it. I don't see why it
    didn't unless there is a spelling mistake or something. If there
    is you should have a got an error message. :-)
    I actually don't recommend using globals at all, I would rather
    use a PL\SQL Package Specification to define Global Variable.
    These variables are valid for the duration of the Session and
    they are restricted to Char(255) limit. It reduces the number of
    mistakes when converting dates and Such. It also forces the
    developers to place all the globals in one place instead of
    multiple places. Read Feurstein's book on PL\SQL Programming for
    more details.
    Sunil
    MS Ganesh (guest) wrote:
    : Hi Steve,
    : I know how to assign values to global variables.
    : I did the following
    : Form Name : FIRST_FORM
    : :global.group_id := 'SUPERVISOR'
    : call_form('SECOND_FORM');
    : In Second Form
    : When New Form Instance
    : Message(:global.group_id);
    : No message is displayed.
    : Please explain to me the steps in detail.
    : Thanks in advance.
    : Bye
    : MS GANESH
    : Steve (guest) wrote:
    : : Just assign value to global variable i.e.
    : : :global.foo := 'anything'; or
    : : COPY('anything', 'global.foo');
    : : to remove global variable
    : : ERASE('global.foo');
    : : Note: global variables are always VARCHAR2(255);
    : : MS Ganesh (guest) wrote:
    : : : Dear OTN Members,
    : : : I would like to pass values between forms,
    : : : I know it is possible to do it by using Parameters.
    : : : But I would like to know how to use global variables to
    : : : accomplish the same task.
    : : : Thanks in Advance.
    : : : Bye
    : : : MS Ganesh
    null

  • How to access classes in jar files

    hi I have added a jar file to my project in eclipse.How to access the classes in that jar file?

    cu is right.
    classloader returns the URL of your resource. You can the jar using something like the following...
    ClassLoader classloader = this.getClassLoader();
    url = classloader.getResource("your_resouces...");
    if(url == null)
    System.out.println("cannot find resource ");
    return null;
    String jar = url.getFile();
    jar = jar.substring(jar.indexOf("/")+1, jar.lastIndexOf("!")).replace('/', '\\');
    obviously, this code snippet works on windows only. Now you have the jar file path. I use Jar file classes to access the jar file. (e.g. you can search for each class files)
    Ming

  • How to access class members in jsp??

    i m working in jsp and i make a class Student having attribute name and id and i store it at tomcat\classes\Student.java
    and i store a jsp page at tomcat\webapps\root\student\index.jsp
    now i create object of class Student in jsp page it works
    but when i try to access name(Student.name) or id(Student.id)(or any class member of Student class)it shows error message
    now pls tell me how can i access class members in jsp page.

    i m working in jsp and i make a class Student having attribute name and id and i store it at tomcat\classes\mypack\Student.java
    and i store a jsp page at tomcat\webapps\root\student\index.jsp
    now i create object of class Student in jsp page it works
    but when i try to access name(Student.name) or id(Student.id)(or any class member of Student class)it shows error message
    now pls tell me how can i access class members in jsp page.
    Note: class members r public.

  • How to access a variable from within a symbol.

    How do I access a variable set outside a symbol from within that symbol?
    Thanks

    If you set a variable on stage ,say
    sym.setVariable("stageVariable", "I am stage variable");
    You can access it from within  a symbol using :
    var myVariable = sym.getComposition().getStage().getVariable("stageVariable");
    Basically you need to get handle to the symbol in which the variable is defined.

  • How to access a variable in if clause?

    Hi Friends,
    I have declared a varialbe like this
    <?xdoxslt:set_variable($_XDOCTX, ’cnt’, 10)?>
    Now if i want to access the variable in "if" clause ,something like
    <if:cnt=10?>
    How can i access it?

    Hi,
    try the following
    <?if:xdoxslt:get_variable($_XDOCTX, 'cnt')= 10?>
    Your logic goes here
    <?end if?>
    regards
    Rupesh

  • How to access Workflow variables in Form Designer?

    Hello,
    I am wanting to set certain subforms to readonly depending on which part of the workflow the form is currently on. I already have the JavaScript code working to set the subform fields to readonly, but now I cannot figure out how to trigger this and where do I keep a variable to keep track of which part of the workflow I am currently in.
    I assume I will have a variable in the workflow itself and then I can use the Set Value QPAC to change the variable for each workflow step before it goes to the User QPAC, but what about within the form? I don't understand how the form javascript will know to execute, so how does my workflow "talk" to the form to set these fields to readonly?
    Right now the JavaScript code is sitting in the root::initialize part of the form. I was assuming I could have something like "if my workflow variable is equal to XX then set this subform to read only". But, how do I access my workflow variable in the form designer?
    Also, since I have digital signatures, I am having to pass all the form data in document variables, will this affect how I need to do this? I was also thinking of possibly accessing/setting a hidden field in the form, but thought the above way may be better.
    I hope that made sense!
    Thank you,
    Jennifer

    To follow-up, I spoke with Adobe support this morning and they said that I cannot access Workflow variables within Designer (besides those Workflow variables that are already provided).
    He mentioned that if I use the hidden fields, that I would need to Render the form each time before going to the User to trigger this to happen. So, I am not sure what I will do just yet. I probably not worry about making the fields readonly for the time being; it was a little extra thought I had and isn't required for our process.
    Thank you,
    Jennifer

  • How to access Websphere variables using java

    Hi
    I want to access Websphere variables using java.
    Any help is appreciated!!
    Thanks
    P

    WebSphere Application Server has a bunch environmental variables such as log locations. These are held at the "server", "node", and "cell" level.
    To access them, you have to get the right context. Something like this, I believe...
    InitialContext initialContext = new InitialContext();
    initialContext.lookup("foo:bar/baz/blah"); //correct context hereGo to the IBM website for WAS and do a search on namespace bindings. That should give you some more information.
    Good luck.

  • How to access static variable from a Thread class

    Kindly help me.......
    here's the code.....
    class Thread1 extends Thread
    int j=0;
    myClass2 mc = new myClass2();
         public void run()
              for( int a=0;a<6;a++)
                        {try
                             { Thread.sleep(5000);
                             catch(Exception e){System.out.println("Interrupted Exception");}
                             j++;
    mc.change1(i);
    } System.out.println("Thread1 executes "+j+" times");
    class Thread2 extends Thread
    int k=0;
         myClass2 mc1 = new myClass2();
         public void run()
              for( int a=0;a<6;a++)
                        {try
                             { Thread.sleep(5000);
                             catch(Exception e){System.out.println("Interrupted Exception");}
                             k++;
    mc1.change2(i);
    }System.out.println("Thread2 executes "+k+" times");
    class myClass2
    static int i=5;
    public synchronized void change1(int s)
    s=6;
    System.out.println("New value of i:"+s);
    public synchronized void change2(int s)
    s=7;
    System.out.println("New value of i:"+s);
         public static void main(String args[])
    Thread1 b1 = new Thread1();
    Thread2 b2 = new Thread2();
         b1.start();
    b2.start();
    I am unable to pass the variable i in my method call in Thread1: mc.change1(i); and similarly in Thread2:mc.change2(i);

    You can declare your i variable in myClass2 as public static and then simply call there
        mc.change1( myClass2.i ) ;

  • How to access workflow variables from business classes?

    In WLI2.1 the com.bea.wlpi.server.admin.Admin bean was useful to retrieve workflow
    variables for a particular instance id.
    Is there anything similar in 8.1?
    We have to do the following:
    In the workflow, when a particular task gets created, a user (claimant of the
    task) should be able to pull the workflow xml data in a JSP. The user may update
    the data from the JSP and then the updated xml needs to be saved in the workflow.
    Then, onTaskCompleted, the updated xml will follow the rest of the workflow.
    How to do this is 8.1?
    Thanks in advance.

    Hi,
    Pls check for setRequest/setResponse in task control and setTasksRequest/setTasksResponse
    i task worker control. Hope this will resolve your issues as they have XmlObject
    as parameter.
    Regards
    Sai
    "Aparna" <[email protected]> wrote:
    >
    In WLI2.1 the com.bea.wlpi.server.admin.Admin bean was useful to retrieve
    workflow
    variables for a particular instance id.
    Is there anything similar in 8.1?
    We have to do the following:
    In the workflow, when a particular task gets created, a user (claimant
    of the
    task) should be able to pull the workflow xml data in a JSP. The user
    may update
    the data from the JSP and then the updated xml needs to be saved in the
    workflow.
    Then, onTaskCompleted, the updated xml will follow the rest of the workflow.
    How to do this is 8.1?
    Thanks in advance.

  • How to access class method in jsp page

    hi ,
    I am new to JSP . I want to access a method returning an arraylist
    of a class.
    this class i saved in WEB-INF>classes folder > where other classes like logonform , etc. are saved ....
    import stmt is <%@ page import="java.io.*, java.util.*, readXml " %>
    <% readXml rd= new readXml();
    Arraylist list=rd.parseDoc();
    %>
    It is not recognizing readXml class......
    Can any body help me in this regard......
    plz help .... i m in urgent need
    thanks in advance.......

    better to put class in a pkg inside webinf> classes folder ...
    but in my case constructor was not public......
    public readXml(){}
    now it works fine...... :)

  • How to access a variable in workflow

    Hi All,
    1)Can a user-defined variable be accessed in workflow? If yes,how??
    2) whether or not every idoc function runs in the workflow or only workflow specific functions can be used there?
    (idoc reference guide says nothing abt whether non-workflow functions working under workflowcustomization area)
    3)I am trying to pull all the metadata options (multiselect) options in a variable and then i want that variable (which will now contain a string) to be used as a token .how can i go for it?
    4)where can we see the output of idoc scripts when we write customization scripts in UCM (apart from the reflection of changes happening if the script is proper)
    Thanks in Advance.

    I think what you are saying is that you want to create a token based on the values in a metedata field that is popuated by a multiselect list. This requires that you have a multiselect list where you add user ids to a metadata field
    To do this from the Workflow Admin applet
    Options > Tokens... > Add
    Give the Token a Name and Description and then paste the following into the script area
    You will have to change the value of xReviewers to the name of your custom metadata field.
    <$rsMakeFromString("wfReviewers",xReviewers)$>
    <$loop wfReviewers$>
    <$wfAddUser(wfReviewers.row, "user")$>
    <$endloop$>
    Is this what you need?
    Tim

  • How to access enviroment variables on 10.1.2.3??

    We would like to add and access the environment variables from jsp/java, does anyone know how to do so? We have added them to the server in the env var section, but are unable to access any of them?! Help!

    Tried that. Throws a genEnv is deprecated error. It does however work on 10.1.3. (which is frustrating) I switched it to use the java.util.Properties p = System.getProperties(); But it doesn't show up in that list either.

Maybe you are looking for

  • How to generate XML file from oracle database query result

    Hi dudes, as stated on the subject, can anyone suggests me how can i achieve the task stated above?? Here is a brief description of my problem: I need to create a XML file once i query from the oracle database, and the query result returned from the

  • JDeveloper 11.1.1.2.0 Support for Dimension Express

    The JDev extension for Dimension Express is not working correctly. After downloading, and successfully connecting to the repository, none of the versioning menu items are enabled? The documentation is also inconsistent with the actual procedure to co

  • How to Get Down Payment Amount associated to one customer invoice

    Hello Experts, I have an issue and i need your help. I have one customer invoice in FI (Transaction FB70). In my form, i need to print the Down Payment Amount associated to this customer invoice. How can i get this information? I mean this amount. Th

  • Persisted Sessions Count in Tomcat5.0

    I am using Tomcat5.0. I want to find the exact number of sessions associated with application running in the server. By using HttpSessionListener i wrote my logic.So that i can count the number of sessions.My Problem is, Suposse if i stop my tomcat s

  • How can i replace all parenthesis text in a document ?

    Hi everyone ! I'm a designer and i know nothing about scripting. But actually i would like to remove a bunch of text. I am working on a map, and i need to get rid of all text in parenthesis (the parenthesis included in). I know there will be a faster