Detaching the model from the component

Many Swing components such as a JTextComponent have a separate model for the data. I'm concerned about what happens when that model backs multiple components, for example a single Document that is used by multiple JTextFields. Generally listeners are added to the model to update the component when it changes, but when/where are they removed? I was just looking through JTextComponent/JTextField and don't see any place it's being cleaned up.
So what happens when the model is backing two components, one which is in a containment hierarchy and one which is no longer in a containment hierarchy and has been discarded? Since the references are concrete I don't see how it can be collected. I'm trying to figure out what the convention is regarding this. Do you keep weak references to listeners? Do you simply not use a model to back multiple components? Do you override removeNotify() (or some other method) to remove listeners (and if so, what do you override to add them again if you get added to a containment hierarchy again)?
Any advice is appreciated.
waits for camickr

The only think I can suggest is to try
textComponent.setModel( null ). Before adding
DocumentLIsteners to the new model it removes the
DocumentListeners from the old model.I'm not so much concerned with swapping models as I am what happens when I have one model backing multiple components. Say I have some data that for the purposes of the GUI is backed by a Document. If I want to display that data, which might even be something that can be mutated by the user, then I use that Document. In the case of a JTextComponent it already uses a Document for it's model so you simply set the model to be your own Document. Now every JTextComponent displays the right data and can update the correct data.
The problem is what happens when some part of the GUI is discarded and it contains a component that is backed by this model? Either the entire thing being discarded needs to be self-contained and not attached to anything you're holding on to (or vice versa), or it needs to have some mechanism to detach it. How does Swing do it? I've been thinking there must be something to deal with this, something fired when it's removed from a containment hierarchy. For example, why in the world would a JTextComponent that's not even in a containment hierarchy keep updating itself when the model changes?
I found removeNotify() but from it's documentation I'm not sure if it's appropriate and JTextComponent doesn't seem to remove listeners anywhere unless you change the model. I'm quite perplexed as to how (or perhaps when) the actual visual component gets detached from whatever it needs to function when it's no longer being displayed (e.g. I removed it from the frame and no longer have a reference to it).

Similar Messages

  • The description for Event ID 0 from source VSTTExecution cannot be found. Either the component that raises this event is not installed on your local computer or the installation is corrupted. You can install or repair the component on the local computer.

    Hi,
    Can any one help me on the below issue ?
    while executing automated test case in test center it is showing as test case is in progress, then i navigated to virtual machine (where the test agent is online), there Internet
    explore has opened automatically and my test case execution started, but with in a seconds IE has closed . However, in test center, test case status is showing as in
    progress, after  2 or 3 min  some of  test cases getting passed and some are failed.
    Here my question is in lab center-->virtual machine, IE has opened automatically and navigated the 2 or 3  links and with in seconds IE has getting closed. Why IE is getting closed without completing execution?
    Error Message :
    The description for Event ID 0 from source VSTTExecution cannot be found. Either the component that raises this event is not installed on your local computer or the
    installation is corrupted. You can install or repair the component on the local computer.
    If the event originated on another computer, the display information had to be saved with the event.
    The following information was included with the event: 
    (mtm.exe, PID 5240, Thread 4) FileAggregatorSessionInfo: Error occurred while deleting temporary directoryException: System.IO.DirectoryNotFoundException: Could not find a part of the path 
       at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
       at System.IO.Directory.Delete(String fullPath, String userPath, Boolean recursive, Boolean checkHost)
       at Microsoft.VisualStudio.TestTools.Execution.Aggregation.FileAggregator.FileAggregatorSessionInfo.DeleteTemporaryDirectory(String temporaryDirectory)
    the message resource is present but the message is not found in the string/message table
    Thanks
    Suresh
    Suresh

    Hi,
    Can any one help me on the below issue ?
    while executing automated test case in test center it is showing as test case is in progress, then i navigated to virtual machine (where the test agent is online), there Internet
    explore has opened automatically and my test case execution started, but with in a seconds IE has closed . However, in test center, test case status is showing as in
    progress, after  2 or 3 min  some of  test cases getting passed and some are failed.
    Here my question is in lab center-->virtual machine, IE has opened automatically and navigated the 2 or 3  links and with in seconds IE has getting closed. Why IE is getting closed without completing execution?
    Error Message :
    The description for Event ID 0
    from source VSTTExecution cannot be found. Either the component that raises this event is not installed on your local computer or the installation is corrupted. You can install or repair the component on the local computer.
    If the event originated on another computer, the display information had to be saved with the event.
    The following information was included with the event: 
    (mtm.exe, PID 5240, Thread 4) FileAggregatorSessionInfo: Error occurred while deleting temporary directoryException: System.IO.DirectoryNotFoundException:
    Could not find a part of the path 
       at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
       at System.IO.Directory.Delete(String fullPath, String userPath, Boolean recursive, Boolean checkHost)
       at Microsoft.VisualStudio.TestTools.Execution.Aggregation.FileAggregator.FileAggregatorSessionInfo.DeleteTemporaryDirectory(String
    temporaryDirectory)
    the message resource is present but the message is not found in the string/message table
    We are using VS 2013 (premium) and IE 10.0,  scripts have been created on the same versions. It is working fine  on
    developers command prompt but the same tests are getting failed in lab center test agent machine
    test agent log:
    QTAgentService.exe, AgentService: calling AgentObject.RunEndFileCopyComplete
    QTAgentService.exe, AgentProcessManager.WaitForDataCollectionAgentProcessToStart: waiting for agents to start.
    QTAgentService.exe, AgentProcessManager.WaitForDataCollectionAgentProcessToStart: Agents started.
    QTAgentService.exe, AgentProcessManager.PerformActionIgnoringExceptions: Successfully called 'Cleanup' on the test agent
    QTAgentService.exe, AgentProcessManager.PerformActionIgnoringExceptions: Calling 'StopDataCollection(int)' on the data collection agent
    QTAgentService.exe, AgentProcessManager.IsDataCollectionAgentNeeded: IsExecutedOutOfProc? True
    QTAgentService.exe, AgentPro
    QTAgentService.exe, AgentProcessManager.WaitForDataCollectionAgentProcessToStart: Agents started.
    QTAgentService.exe, AgentService: Connection to controller is up.
    Thanks
    Suresh

  • How can i detach the video from a clip so i can only use the audio when using imovie?

    how can i detach the video from a clip so i can only use the audio when using imovie?

    First, go to iMovie/Preferences and enable the Advanced Tools.
    Import the video clip into an iMovie Event. When you get ready to use it in an iMovie Project, select the clip in the Event and drag & drop it on top of a video or photo clip in the project at the place where you want it to begin. When the pop-up menu appears, choose Audio Only.

  • How do I insert/Delete/Update a row to the DB Table from Business Component Browser

    I am using the wizard and created a project containing Business component which contain some table.
    When I run the project I could see "Oracle Business Component Browser(local)" and when I select some table from "View Object Member" I get a window displaying all the field of that table and I could browse all the info.
    My Problem is when I try to insert a new record/Delete the existing record or update some record it never gets reflected to the DataBase.
    When I try to insert a new row I did save and there was a dialog box displayed saying "Transaction ID is 1". But finally It's not reflected in the Database.
    Can some one guide me how can I do insert/delete/update operation from Oracle Component Business Browser so that the changes reflect to the Original DataBase.
    Thanks in advance
    Jitendra

    Jitendra,
    This may be a problem of caching. If you do an update,insert, or delete, and do not receive an error, then the transaction should indeed be posted.
    I assume you are hitting the Save icon after your changes if you are getting a transaction ID. Are you checking for the updates through another session (i.e. SQL*Plus), or do you then requery the View Object in the tester? Do you exit the tester and come back in and not see the changes?

  • Reading the data from one component view into another component view

    Hi All,
    I have requirement to read the data from one component into another component while creating the service order. Here are the details.
    Main View for Service order: BT116H_SRVO in that we have two assignment blocks like Organizational data(BTORGSET) and amount allocation(BTAMNTALL).This two blocks are two different component which are associated with main component(BT116H_SRVO).
    I need to read the sales org data from component/View(BTORGSET/Orgsetdata) into Component/View(BTAMNTALL(HdrBillPlanDet) method DO_VALIDATE_INPUT.
    I searched in SDN but all the posts are related to the data exchange between two views in same component. But My scenario is different as explained above.
    Refer the attachments for the component link..
    Please let me know how we can achieve this one..
    Thanks,
    Sapsar.

    Finally I was able to fix my code...My Mistakes were need to read the parent node above three levels and need to use the relation entity name while reading the data..
    Below is the correction code
    IF iv_index IS NOT INITIAL.
         lr_iterator ?= collection_wrapper->get_iterator( ).
         lr_current ?= lr_iterator->get_by_index( iv_index ).
         lr_entity ?= lr_iterator->get_by_index( iv_index ).
       ELSE.
         lr_current = collection_wrapper->get_current( ).
       ENDIF.
    *loop back to root entity
             WHILE lr_entity->get_name( ) NE 'BTAdminH'.
               lr_entity = lr_entity->get_parent( ).
             ENDWHILE.
    *Get the related entity
             IF lr_entity IS BOUND.
               lr_collection ?= lr_entity->get_related_entities( iv_relation_name = 'BTHeaderOrgmanSet' ) .
               IF lr_collection IS BOUND.
                 lr_orgset_m = lr_collection->get_current( ).
    *            lr_orgset = lr_orgset_m->get_related_entity( iv_relation_name = 'BTOrgSet' ).
                 lr_orgset = lr_orgset_m->get_property_as_string( 'SALES_ORG' ).
               ENDIF.
             ENDIF.
    Thanks,
    Sapsar.

  • Calling a method in the view controller from the component controller

    Hi
    Is there anyway to call a method in the view implementation from the component controller??
    Thanks
    jack

    Thanks for all your replies. I want this kind of a functionality because Im trying to invove a DC (Child DC) from a Parent DC such that the Child DC's view is displayed onto the view container of the Parent DC. I have embedded using 'interface view of a component instance' in the Parent Window and am able to create the component and set usage though the onPlugDefault of the Child View.
    But I observe that when i make a call from the parent, the flow is like this:
    1. The wdDoInit of the Child Component Controller gets triggered first.
    2. Then the wdDoInit of the Child's <b>VIEW</b> gets triggered
    3. and <b>THEN</b> the onPlugDefault of the Child Component Interface View
    What I had actually wanted was to Fire onPlugDefault where Im calling a method LoadData(), after which the Child DC's view must be triggered so it can display the fetched data.
    What is actually happening is the view gets displayed, but no data is displayed in the view.
    Right now I have just given a work around where Im triggering <b>LoadData()</b> of the <b>COmponent COntroller</b> from the <b>wdDoInit</b> of the <b>VIEW</b>.
    Is there a better way to do this? I find it strange that I have to load the Data from the view.
    Thanks
    Jack

  • Drag the component from one cell to another cell within JTable

    Hi All,
    I have one requirement to drag the component from JList to JTable cell. I am able to do it but once if i drag the component from list to table cell, table accepting the drop after this i am unable to move the same component from one cell to another cell within the table.
    Any advice.
    I have used the following logic for JTable and JList is drag enabled.
    DefaultTableModel tableModel=new DefaultTableModel(
                new Object [][] {
                    {null, null, null, null,null,null,null},
                    {null, null, null, null,null,null,null},
                    {null, null, null, null,null,null,null},
                    {null, null, null, null,null,null,null}
                new String [] {
                    "Title 1", "Title 2", "Title 3", "Title 4","Title 5","Title 6","Title 7"
            JTable table = new javax.swing.JTable(){
                public boolean isCellEditable(int row, int column)
                    return false;
            table.setModel(tableModel);
            table.setDragEnabled(true);
            table.setDropMode(DropMode.INSERT);
            table.setTransferHandler(new TransferHandler(){
                public boolean canImport(TransferHandler.TransferSupport info){
                    if (!info.isDataFlavorSupported(DataFlavor.stringFlavor)){
                        return false;
                    return true;
                public boolean importData(TransferSupport support) {
                    if (!support.isDrop()) {
                        return false;
                    if (!canImport(support)) {
                        return false;
                    JTable table=(JTable)support.getComponent();
                    DefaultTableModel tableModel=(DefaultTableModel)table.getModel();
                    // fetch the drop location
                    JTable.DropLocation dl = (JTable.DropLocation)support.getDropLocation();
                    int row = dl.getRow();
                    int col=dl.getColumn();
                    // fetch the data and bail if this fails
                    String data;
                    try {
                        data = (String)support.getTransferable().getTransferData(DataFlavor.stringFlavor);
                    } catch (UnsupportedFlavorException e) {
                        return false;
                    } catch (IOException e) {
                        return false;
                    calendarTableModel.setValueAt(data, row, col);
                    return true;
            });Thanks & Regards,
    Maadhav.
    Edited by: maadhav on Jun 23, 2009 12:29 AM

    Hi All,
    I fixed this issue with some additional logic which allow me to drag and drop the string component from one cell to another cell within in the JTable.
    I am attaching the new logic here, if any one needs use it.
    DefaultTableModel tableModel=new DefaultTableModel(
                new Object [][] {
                    {null, null, null, null,null,null,null},
                    {null, null, null, null,null,null,null},
                    {null, null, null, null,null,null,null},
                    {null, null, null, null,null,null,null}
                new String [] {
                    "Title 1", "Title 2", "Title 3", "Title 4","Title 5","Title 6","Title 7"
            JTable table = new javax.swing.JTable(){
                public boolean isCellEditable(int row, int column)
                    return false;
            table.setModel(tableModel);
            table.setDragEnabled(true);
            table.setDropMode(DropMode.USE_SELECTION);
            table.setTransferHandler(new TransferHandler(){
              public int getSourceActions(JComponent c) {
                    return DnDConstants.ACTION_COPY_OR_MOVE;
                public Transferable createTransferable(JComponent comp)
                    JTable table=(JTable)comp;
                    int row=table.getSelectedRow();
                    int col=table.getSelectedColumn();
                    String value = (String)table.getModel().getValueAt(row,col);
                    StringSelection transferable = new StringSelection(value);
                    table.getModel().setValueAt(null,row,col);
                    return transferable;
                public boolean canImport(TransferHandler.TransferSupport info){
                    if (!info.isDataFlavorSupported(DataFlavor.stringFlavor)){
                        return false;
                    return true;
                public boolean importData(TransferSupport support) {
                    if (!support.isDrop()) {
                        return false;
                    if (!canImport(support)) {
                        return false;
                    JTable table=(JTable)support.getComponent();
                    DefaultTableModel tableModel=(DefaultTableModel)table.getModel();
                   JTable.DropLocation dl = (JTable.DropLocation)support.getDropLocation();
                    int row = dl.getRow();
                    int col=dl.getColumn();
                    String data;
                    try {
                        data = (String)support.getTransferable().getTransferData(DataFlavor.stringFlavor);
                    } catch (UnsupportedFlavorException e) {
                        return false;
                    } catch (IOException e) {
                        return false;
                    tableModel.setValueAt(data, row, col);
                    return true;
            });Thanks & Regards,
    Maadhav..
    Edited by: maadhav on Jun 23, 2009 5:26 AM
    Edited by: maadhav on Jun 23, 2009 5:28 AM

  • Catching an error from the component level in a plan?

    I have components that installs a software package (using the LINUX rpm install plugin). These components are called in sequence from an SPS
    "Plan". If any one of the rpm's to be installed by the plan might already have been installed, the rpm exits with an error message and a "1" exit code.
    That exit, causes the whole install to stop dead in its tracks.
    I have tried a "try and catch" to be allow the installation to continue
    when that situation exists. Howvever, at the "Plan" level all I can catch is
    any error. If a bad error; that is one that is not an "Exit 1" because the
    rpm was already installed, but rather something that needs to stop the
    entire plan ... the "catch" will ignore those errors as well.
    Without modification of the SUN component install plugin, how in XML does one know what the exit code is from the install plugin
    (a) within the component that calls the install plugin
    (b) insde the plan XML that calls the component XML that calls the plugin
    Are there global variables, passed return codes, inherited parameters or something that facilitates the passing of exit codes from plug-in to XML component to XML plan?

    Hi,
    Hope you have gone through the mentioned Notes for the pre-requisites. I checked the second Note which shows New and can not be implemented.
    You can check whether the similar Notes have already been implemented in your system. Check with your BASIS team
    Regards,
    Suman
    Edited by: Suman Chakravarthy on Sep 11, 2011 11:59 AM

  • I need a Functional module to get the header material from the component .

    Dear Guru's
    Please help me .
    I need a name of the Functional module to get the header material from the component .
    As in if I put the Component in the Input I should get ALL the Main header materials using this Component.
    Regards,
    Roshan Lilaram Wadhwani.

    This was not answered

  • Problem with "Capture Server Model from the Database"

    I've installed Oracle-Developer-Suite 10g and Designer 9.0.4.5.6. The repository databse is Oracle 10g and the application database is Oracle 9i (about 700 tables for the application). After I started the Designer Editor, I got the follwoing message:
    "No network notification service has been configured for this Repository instance. A desktop-only notification has been started."
    What does it mean? What's wrong with the configuration? How can I avoid this problem?
    Then I tried to "Capture Server Model from the Database". It took hours to read the data from the database. After reading the data, the following message occurs:
    "138 overlaps could not be eliminated by AutoLayout as there is insufficient room to layout the items. Select a large area and retry"
    I can not save the uncommited data into the repository.

    1. Designer 9i was made to capture 9i DB functionality. So no it will not capture full 11 DB functionality.
    2. Yes I have had some problems capturing from an 11DB and have written a bug on it.
         Bug.7138247     (74) CANNOT DESIGN CAPTURE A TIMESTAMP(6) FROM 11G DB:
    this is fixed in Designer 10.1.2.5

  • How to detach refresh button from address bar in the new UI of FF29?

    IN FF28 it was possible to detach the refresh button from the address bar, but now the whole address bar is just one element. I am really used to have the button on the left side and not on the right side of the screen. I would love to have the opportunity back again to separate them!
    Best,
    Robin

    Firefox is just caught up in the industry wide disease of simplifying their user interface to satisfy the needs of mobile device users. It's probably true that they make up the vast majority of users. It is troubling that this trend ruins the experience for the few of us that still use powerful computers with huge and multiple display screens.
    As a developer of web pages, I often go through a cycle of looking at a web page I am developing, tweaking it, and refreshing the browser. No matter how many times I just proofread the content, I still find mistakes that need correction. So the view, correct, refresh cycle is so frequent that I need it to be efficient with well placed controls to accomplish the cycle.
    I don't mind making the GUI extremely simple for the majority of users, but I am upset with how often these "improvements" make it difficult for the experienced user/developer to use the tool in the way that suits them.

  • Move the component which expried from the production area to the blaocked

    Hi
    we maintain the same storage location for production area and raw material storage area under the ware house.
    by differentiate by storage type.
    now we need to move the component which expried from the production area to the blaocked stock
    which t.code
    thanks
    vraj

    Process is Normal only. Go to MB1B. Use 344 Movement type. A Material document is created. A PCN is automatically created. Now convert the PCN to TO by LT04/LT06. Here you have to give your storage type as your production area.

  • From an ItemRenderer, how can i reach the component that the Itemrenderer is applied on

    Hello.
    I have a component that uses a skin that uses several different item renderers.
    in each item renderer i want to set a different background color according to a public variable that
    the component that i apply the item render on has.
    how can i reach that component from the ItemRenderer?
    thanks!

    Usually outerDocument or parentDocument.

  • Why is useful to separate the model from the view in Swing?

    As I have read a few times, swing implements the model-view-controller pattern and I think I understand why to separate the controller from the model and view but not why to separate the model from the view, why is this useful?
    Thanks

    J_MARTINEZ wrote:
    Ok, got it but how can I control the view because for I�ve read in swing you just modify the model in the components. For example, if I have a JProgressBar and I use the method setValue(int) to fill the bar, I am modifying the proeperty value in the model but I dont have control for the view.I'm not sure I know what you mean here. If you change the model, the view will automatically update itself and display the changed value. You should have a look at some of Swing's source code such as AbstractButton and DefaultButtonModel. There you'll see that the view adds (I think, it's been a bit since I looked myself) a ChangeListener to the Model that the model uses to notify the view of any changes.

  • I need the SPICE Model for DS1809 or the component in Multisim. Help mee!

    Hey people, I need the SPICE Model for DS1809 (Digital Potentiometer) for Multisim. Does anybody have this?? Or any idea where to get. I searched for, but I coudn't find.
    Thank you

    Hi,
    As you can see in this link the part is longer manufactured and it does not have a replacement.
    In terms of functionality, you can try using the component PLL_VIRTUAL in Multisim to replace it in a high level simulation or create a new component of a replacement that you have the SPICE model of.
    Let me know if you need any help.
    Mahmoud W
    National Instruments

Maybe you are looking for

  • Plant my G4's internal disk in new Mac Pro?  Then what?

    Hi all, I'm debating how to transfer existing data on my G5 to my new Mac Pro. There are old applications & stuff I'd still like to access on the G5 but not gum up my new system. This is what I'm considering: * Extract my boot disk from the G4 and in

  • Error while deploying polling dbadapter as proxy service in osb console

    Hi all, I have created a db adapter in Jdeveloper and imported it into oepe. I have create a proxy service from that . Which i have just deployed to verify on doing so i am getting the following execption. <Internal error occured in OSBConsole : null

  • Need help in currency conversion

    i am doing currency conversion at query level. i am getting this error message for the output. Diagnosis The exchange rate 19.334.782,61- was calculated via the base currency INR. This produced a rate which exceeds the maximum allowed value of 9999.9

  • Connect database

    hi all, I already opened Database in one terminal now i try to open in new terminal for some other command execution but it comes [oracle@localhost ~]$ export ORACLE_BASE=/u01/app/oracle [oracle@localhost ~]$ export ORACLE_HOME=/u01/app/oracle/produc

  • Can't get 3D sound effects to work in gam

    I have a Sound Blaster Audigy 4 card and it used to work just fine. Now, I get sound out of all 5. channels, but the 3D effects do not work in games (Doom 3, F.E.A.R.). I tried updating the drivers, and even re-installing the card, but nothing seems