Question on the scope, theoretical

Hello

I have a question on the scope. It's something that I'm probably not on Java and OBJECT oriented programming.

I am writing a program, that can handle several documents (images) of simple image processing. Now I have a DialogNewGUI with an actionPerformed method. In this method, I test for the appropriate action command and if NEW is the action command that I should create a new document (for example, a Document class). What worries me is that if I create an instance of a Document class in the scope of the actionPerformed method, we only see in this method, right? So, how do I access these Document instances newly created throughout the entire application? I think, I need a kind of global variable holding a reference to the Document instance, so I can work on it from anywhere in the code, but I don't think that there is such a thing in Java as global variables. I thought that, maybe, I need to create a class, called Basic, to contain the references in the world, but I don't know if I'm not running in the same issue there either.

Someone has an idea? Thank you

PR

It is not clear what exactly you're trying to do. If you want to keep track of documents (images) which currently manages your image processing system, you will need to add in some kind of a collection - Let's say a card openDocuments, which in turn is handled by another class - let's call it imageProcessingSystem. You should then be able to add and to remove documents from the collection and to keep track of documents course of treatment.

Tags: Java

Similar Questions

  • question on the scope of the stage object

    Hello, all.  I am currently working with containers and I have a question about the stage object.

    I have 2 files in my program

    (1) app.as

    (2) stuff.as

    Stuff.As is a library of common user interface that I build.  I'm trying, in this document, follow these steps:

    stuff(){
    
    makeUI();
    
    }
    
    makeUI(){
    
    myContainer.setSize(stage.Stagewidth , stage.Stagehight);
    
    }
    

    Flash crash when running, saying that there is a reference not valid for a null object.

    If main.as is the file of the application, how can I get the stage object to be valid / available inside my stuff.as file?

    -Thanks for your time!

    Hey dtater,

    I met the same problem too in the past. the only way to have access to the stage is to have the class that never work added to the stage by a parent object that is already on scene. If an object has not yet been added to the stage, his stage value will be null.

    the best way to work with this set of return must have an event listener defined in your file stuff.as to listen for Event.ADDED event in your stuff() constructor like this:

    this.addEventListener(Event.ADDED, onAdded);
    

    and then in your event handler function onAdded:

    private function onAdded(e:Event):void{     // this event gets triggered by other objects, so we check to make sure it the right object     if (e.target == e.currentTarget)      {          makeUI();
    
         }
    
    }
    

    in this way the makeUI funciton only will be called when it has access to the scene.

    Here are more details on the event Event.ADDED:

    http://www.Adobe.com/LiveDocs/Flash/9.0/ActionScriptLangRefV3/Flash/events/event.HTML#added

    hope that helps. Good luck!

    Edit: I also forgot to add that the Event.ADDED event will be called when you addChild (stuff); in your main application.

  • Question on the scope and the framework / time line

    Hello!

    I write a little app and have the buttons and sliders on a field 1 of the scene and then a help screen on frame 2 of the scene.

    I have event listeners attached to the objects of the first image.  When I go to the second image and then return to the first image, all event listeners are passed away and no longer work.  (at least that is what I think is happening).

    My question is what is the best way to deal with this.  I think the best way would be to add something like adding Event listeners. ADDED_TO_STAGE for each object and have the listener function add event listeners I want for each item.

    So I will:

    public function Document()

    {

    Super ();

    iSlider.addEventListener (Event.ADDED_TO_STAGE, added);

    iSlider.removeEventListener (Event.REMOVED_FROM_STAGE, withdrawn);

    myButton.addEventListener (Event.ADDED_TO_STAGE, buttonAdded);

    myButton.addEventListener (Event.REMOVED_FROM_STAGE, buttonRemoved);

    }

    In each of the listeners, I would add / remove listeners that respond effectively to the key / slider.

    Is the best way to do it, or I missed something.  Sorry about the silent nature of this question, but I'm gay.  I hope someone less gay can help out me.

    -Thank you

    you are probably missing when you move to the structure 2.  It is a problem when using as3.

    an appeal is to remove your objects in the scene (using code - NOT the timeline) in box 2.  (re) you can add them to the stage in frame 1.

  • Question about the scope of the object and memory.

    I created a class that extends Sprite.

    In this class, I have a private type BitmapData var

    I then add the Sprite as a child to another Sprite on the stage.

    Later, I delete the second Sprite (parent) of the scene and I put the variable referring to it to null.

    After the garbage collection (assuming that it happen correctly) there is no trace of the BitmapData?

    No, unless you did something extra.  If you cannot reference your bitmapdata object (and has no listener), he is eligible for gc.

  • question about the scope of variables and memory

    I searched the Adobe documentation for an overview, but apparently, I'm not in the right place.

    Here is an example of simplified code:

    < AS >

    loadedImages:Array = new Array();

    function createImageData(imageNumber:Number):void
    {
    var imageData:BitmapData = new BitmapData (width, height);

    Switch (imageNumber)
    {
    case 1:
    imageData.draw (loader1.content);
    loadedImages [imageNumber] = imageData;
    break;

    case 2:
    imageData.draw (loader2.content);
    loadedImages [imageNumber] = imageData;
    break;
    }
    }

    < virtue >

    ImageData defined inside the function createImageData(), I know that I can not access any outside level of the function block.  But what about memory?  ImageData still exist once the code has "left" the createImageData() function?

    For example, if the function above is called twice (once with imageNumber = 1, once with imageNumber = 2), what I remember?

    -BitmapData objects stored in loadedImages [1] and loadedImages [2] and 1 BitmapData object named imageData

    -BitmapData objects stored in loadedImages [1] and loadedImages [2] and 2 BitmapData named imageData objects

    -BitmapData objects stored in loadedImages [1] and loadedImages [2] and nothing else

    Is there a way to see the 'elements' in memory, not just the quantity?

    If you call twice createImageData, for imageNumber = 1 and imageNumber = 2, there will be only 2 persistent objects to the Bitmap in memory, and they will be made by the loadedImages table. The imageData variable is just the first to receive the pointer to the allocated memory and past him on the elements of the array until it's life is over. Only when you delete the table, you will release the objects for the GC.

  • question of the scope of variables

    Hi guys,.

    Select book_key
    books
    where exists (select book_key from the sale)

    If we have the above query, it means that the book_key in sales is independent of the book_key in the books? As far as I see it, all what we are doing is saying that if a book_key exists in the table sales, then we want to return the books book_key. In other words, the book_key of books doesn't have to exist in sales.

    It seems completely different from

    Select book_key
    books
    where book_key in (select book_key from the sale)

    because in this case, we want to only return the books book_key, if it exists also in sales.

    Am I wrong?

    Thank you

    OracleGuy777 wrote:
    Hi guys,.

    Select book_key
    books
    where exists (select book_key from the sale)

    If we have the above query, it means that the book_key in sales is independent of the book_key in the books? As far as I see it, all what we are doing is saying that if a book_key exists in the table sales, then we want to return the books book_key. In other words, the book_key of books doesn't have to exist in sales.

    You're right, except that it is saying "If * a * line exists in the sales table": book_key may be NULL for each line in the sale, and the main query will always return each book_key books.

    EXISTS subqueries are almost always correllated to the main request.
    The following Gets the same results as the query you posted using IN:

    SELECT  book_key
    FROM    books  m   -- m for main
    WHERE   EXISTS ( SELECT  NULL   -- The column "selected" makes absolutely no difference
                     FROM    sales
                     WHERE   book_key = m.book_key
                   );
    
  • Question &amp; VI credentials of the scope again

    Just trying to keep quickly my powershell...

    So I created a .ps1 include file that I load in my PS profile by making a point scoring. .\VIinclude.ps1 ... Some of the functions I want to put here are common things as VC connect and disconnect-VC, also define some global variables. For example, these functions to connect to VC using a file of credentials of cookie in read-only format for the statement of the functions of type. The issue I noticed is, when I call these functions of PS by simply entering the function, authentication works and holds for this session. But when I run other scripts in the session that call these functions in the include file, the credential is not retained.  (for example a script dump-vms-in - cluster.ps1 calling definied connect-VC in the include file, does not work, but if I run VC plug then dump-vms... all works)

    What are the rules for the determination of the scope for this kind of thing?

    Question - is there a way to prevent the automatic connection using the currently logged-on user is connect-viserver ?  IN many cases, I want to force PS scripts to always ask authentication, because my rule of thumb is to run scripts with as little as possible privilege on VC/Resource Pools etc to do the job.

    Happy to be told if go and RTps.1FM but I am a prime, second VCP PS guru-wannabe.

    Thanks Peeps, happy vSphereing

    /Kimono/

    I suspect that the Connect-ViServer is called from a function in the include file?

    Then the framing rules begin to play, see also to connect-viserver to remain persistent through different functions..

    This thread also contains a pointer to course of PowerShell of Tobias (strongly advised to have a look).

    You can force a prompt for a username/password by practice

    Connect-ViServer -Server  -Credential (Get-Credential)
    
  • How to insert as an entry within the formula variable, the total time on the scope window?

    How to insert, as an entry within the formula variable, the window of total time on the scope (i.e. of 20ms/div x 10 div = 200ms)?

    HERE'S A SAMPLE QUESTION:

    FORMULA FOR INTEGRAL ACTION:

    STATISTICS:

    Input variable: DPO4034 (CH1);

    Box: number of samples.

    FORMULA

    Input variable 0: DPO4034 (CH1); alias: x 0

    Input variable 1: 'time window Total out of scope?. " alias: x 1

    Input variable 2: number of samples (CH1); alias: x 2

    Under the operation Configuration: formula

    Y = (x 0 ^ 2) *(x1/x2)

    Output: Data 1 (CH1)

    THEN, WITH THE HELP OF STATISTICS:

    Input signal: data processing 1 (CH1)

    Checkbox: SUM

    Output: CH1 integral Action [has ^ 2s].


  • In Labview 8.5, what happens if the input signal exceeds the scope of the signal defined by the DAQ Assistant?

    Hi all

    This should be a pretty simple question, but I can't seem to find the answer online and currently do not have the functionality to test this:

    I'm using LabVIEW 8.5 and have a VI that imports data from sensor through the DAQ Assistant. In the configuration tab, there is a range of signal input. What happens if my sensor exceeds this range? I get a warning? The default value is the maximum (or minimum)? I was interested in writing a code to display an error that I approach the limits of this range, but did not know if I also need to include code to display an error if the scope is exceeded as well.

    Thanks for the help,

    Tristan

    Hello, Tristan,.

    The behavior depends on the selected range and the device you are using.

    If you are using a device with a single input range is valid, we will use this range, even if you set a smaller minimum and maximum in the DAQ Assistant.  So, if your device only supports ±10V and you set the range to ±8V, you will still continue to get valid data after your top sensor 8V until what you approach 10V.  When you reach the limit of the extent of your device, the output will be 'rail', and simply return the maximum value until the signal is less than the maximum value again.

    Note: A device that is nominally ±10V usually has a go-around (such as ±10.2V) which are usually specced in the manual.

    However, if you use a device with several ranges of entry then things become more complex.

    NOR-DAQmx player will choose the smallest range that entirely covers the interval you choose.  For example, suppose that your device supports the following input range: ±0.2V, ±1, ±5V, ±10V and you choose 0V - 3V as the range in the DAQ assistant.  The NOR-DAQmx driver will focus on the input range and the list of the entry lines that your hardware supports and choose the smallest encompassing the entire range that you set.  This would be the ±5V, because this is the only beach that contains up to 3V.  Thus, all between ±5V input signal is returned and none outside this range will be 'rail' to the maximum or minimum value.

    We do this because using small beaches make more efficient use of the resolution of the ADC.  So, we try to use the most effective range based on what you ask without picking up a range that will make you miss data.

    Let me know if I can clarify it more.

  • DFSR Question on the DFSRPrivate folder

    Hello all and thanks in advance for any info you can provide.

    I use DFSR for the first time and I am facing a problem with replicated data and the data from the source. I want to clarify that I use DFSR only for migrating data to a new file server.

    My problem is that when I check the source and destination data, they are the same, according to what should, as I thought that some of the files, if they are open or in use, they cannot be replicated. Well, it seems that this is not true, because I checked it in a test environment. So, after I tested it, I was wondering why the source and destination data are not the same.

    A colleague told me it's because I left the DFSRPrivate folder that contains the intermediate file in its original location in the replicated folder. The advice that it me to change this, which is a huge workload for me now. My question is, my colleague has right? Will I change it?

    This issue is beyond the scope of this site and must be placed on Technet or MSDN

    http://social.technet.Microsoft.com/forums/en-us/home

    http://social.msdn.Microsoft.com/forums/en-us/home

  • Appeal of calendar on the scope of work

    I use the following code to call a container application work, calendar, but the call what follows is invoking the calendar House, not the perimeter of work schedule. When I used a similar code to call the mail client, he called customer of e-mail in the scope of work. Can someone check the code and see what I'm doing wrong?

    Participants QVariantList = QVariantList();
    participants. Append ("[email protected]");
    Data QVariantMap = QVariantMap();
    Data.Insert (QString ("participants"), QVariant (participants));

    Application of InvokeRequest;
    request.setTarget (tr ("sys.pim.calendar.viewer.eventcreate"));
    request.setAction (tr ("bb.action.CREATE"));
    request.setMimeType (tr("text/calendar"));
    QByteArray encData = bb:psObject::encode (data);
    request.setData (encData);
    BB::System:InvokeManager * m_invokeManager = new InvokeManager (this);
    m_invokeManager-> invoke (request);

    We will examine this question. But for now, at least you can specify the ID of the calendar account to use to create the event. Who should call the event create map with the preset specified account.

    Shadid

  • Apart from the scope, is there an advantage between elements of application elements of page zero vs?

    It's the kind of best practices of the question type.

    I understand, the application parts are available throughout the app Page zero points will be available on the pages where page zero is used. But there are basically the same.

    So, outside of the scope, is there an advantage to using application elements vs zero page elements for items that will be used on most of the pages? My use is I have these reference values of almost all the pages and there are some pages that will change the value of this variable. They are not constant.

    Thank you!

    Do you need constants then?  IK them would define as page 0 items that are hidden and cannot be changed otherwise then I would use elements of application to a minimum.  For the most part, I also do not recommend 0 page elements, because they are not passed in and out of shape but are only accessible...

    In a perfect system, you pass in a page, what suits him and, according to the elements of the application and page elements 0 is dangerous in my mind...

    Thank you

    Tony Miller
    Software LuvMuffin
    Ruckersville, WILL

  • Scroll through the question of the effect

    Hello.

    scenario of
    I'll put up an object when you click it, you are returned to the top of the page.

    I chose to use scrolling effects for it.

    Question

    I use a screen 1920 x 1080 and so the effect of scrolling is set to this standard.

    When I test the site on a smaller screen, the object is out of place, or even off screen.

    Is there a way to make the static object, or put it to a point on the screen it always follow when scrolling on any size monitor?
    have


    Thank you!

    You can pin the object in place, so when you scroll down to the bottom of the page that remains in the same position (instead of scrolling effects)

    Given the scope defined on the left side of your screen should ensure that it is visible on all the monitors of size.

  • WHT is the downside of the scope with respect to the operation?

    WHT is the downside of the scope with respect to the operation?

    not 100% sure I understand your question well, but scope is available for the duration of your request - which means that if you insert data in the scope it remains around the life of your application - which can be a drain on resources.

  • Number of question and the navigation sequence.

    Hello and thanks in advance for any help anyone can provide.

    I am using Captivate 5.5, and part of the project is a questionnaire sequence drag-and-drop slide. I have included the ability to go back, because I want the user to be able to go back in the previous section and check the information if they want to. The issue is set to infinite attempts and three levels of failure. Questions are optional and the issue has a clear and a "Skip" button as well as back and submit.

    The problem: when I test the project, I can start the question and use the back button and return to the issue and that works very well. But when I not properly answer the question and THEN use the back button to review previous slides and then return to the question, I am more able to drag and drop the answers. The grey indicator no longer appears, and the answers cannot be moved. I can still use the submit button, but because I can not change the order of response is always bad. I can use the back button, but the issue never becomes mobile. I can use the "Clear" button, but it does nothing. I can skip the question, but it is not very useful because I would like the user to be able to answer the question after reviewing the information and return.

    I don't know about the issue of the scope of quiz, and I click the buttons set up at the beginning and end of the project that are included in the quiz so that I can not leave the scope quiz and mess things this way. But nothing I try seems to correct this problem.

    To sum up, I have a question of sequence, but once the user responds incorrectly and uses then the back button to review information, reverting to the question after it makes the issue frozen somehow, unable to move the responses in the proper order, even if the buttons still work.

    Thank you once again if someone can help me solve this problem!

    I'm really sorry, but that's the way the Question slides are designed to CP5: the number of attempts, you allow the Question level must be exhausted when the user is on the slide. As soon as you leave the question slide will be blocked. Several attempts on the level of play will be always available if you don't let the scope of quiz, but this can be done after completing the quiz, and all responses will then be those deleted, correct as incorrect. This changed to COP6, where sanitation is possible (just answered today such a question in another thread here), and you can access a slide contained a question slide, go back and change the answer.

    Your goal in CP5 is possible if you create custom question slides, but then there is the problem that drag & drop is not available in native mode as you have in the default sequence Question slide.

    Lilybiri

Maybe you are looking for