Model in my JList not reflecting the new value I added to it?

uness I create a new model object and modify it then my code does not work as I want. Adding new data to the exitsting model causes the JList to display blank when I refresh the screen. I have created my own implementation of an editable Model.
When my action performed creates a new instance of the model everything works fine but is this how it should work?
//In my GUI I have a JList initialized with the model ....
private EditableListModel model = new EditableListModel();
model.add("one");
model.add("two");
model.add("three");
colsToDisplayJList.setModel( model );
I have a button with the following action performed
    private void addActionPerformed(java.awt.event.ActionEvent evt) {                                   
        //model = new EditableListModel();
        model.add("four");
        colsToDisplayJList.setModel( model );
//EditableModel implementation
import java.util.*;
import javax.swing.AbstractListModel;
public class EditableListModel extends AbstractListModel
    private Vector items = new Vector();
    public Object getElementAt(int key)
        return items.get( key );
    public int getSize()
        return items.size();
    public void add( String item )
        items.add( item );
    public void remove( String key )
        Iterator iter =  items.iterator();
        int index = 0;
        while( iter.hasNext() )
            String item = (String)iter.next();
            if( item.equalsIgnoreCase( key ) )
                items.remove( index );
                break;
            index ++;
}

That other post looks different, though - the OP is now manipulating the model.The OPs statement of the problem was:
Adding new data to the exitsting model causes the JList to display blank when I refresh the screen.
The suggestion in the other posting was to change the model not the array and the tutorial has a working example of this.
The OPs question was:
When my action performed creates a new instance of the model everything works fine but is this how it should work?
The answer to this is no, you don't need to change the model, just update the model.
So if the OP read the other posting and read the tutorial they should have an answer to their problem.
As you suggested there is no need to create a custom model. The example in the tutorial uses the default list model, if the OP read the tutorial they would know that.

Similar Messages

  • Not reflecting the new value of the AWvariable

    I am working with Jdeveloper and BI beans
    we are using Java Analytical workspace API for connecting and saving the user input as a Analytical workspace Variable
    by using fallowing code
    awConn.executeCommand("awvariable=value");
    here the problem is i can not made this assignment perminent in Analytical Workspace
    i.e after execution of the program i checked with AnallyticalworkSpace manager's worksheet it not reflecting the new value of the AWvariable. It is showing only old value.
    how can i do that assignment it from java api .
    any one can help me

    That other post looks different, though - the OP is now manipulating the model.The OPs statement of the problem was:
    Adding new data to the exitsting model causes the JList to display blank when I refresh the screen.
    The suggestion in the other posting was to change the model not the array and the tutorial has a working example of this.
    The OPs question was:
    When my action performed creates a new instance of the model everything works fine but is this how it should work?
    The answer to this is no, you don't need to change the model, just update the model.
    So if the OP read the other posting and read the tutorial they should have an answer to their problem.
    As you suggested there is no need to create a custom model. The example in the tutorial uses the default list model, if the OP read the tutorial they would know that.

  • Trigger is not updateing the :new value in the table

    Hi,
    I've greated a row trigger that will trigger on insert statements.
    The last thing the trigger will do is to update the :NEW.role_id value in the inserted row, see the trigger bellow.
    The trigger was mutation so I had to add the 'PRAGMA AUTONOMOUS_TRANSACTION;' to avoid the mutation error.
    When performing test with controlled insert statements the trigger is working without problems, but when I my J2EE application is inserting rows to the table the role_id value is nog updated, see the trigger below and the :NEW.role_id := nRole_id; part. The role_id for the new row is empty. What can be the problem?
    CREATE OR REPLACE TRIGGER MSP_36.M2_USER_ALERT_INSERT_TRG_SCA
    BEFORE INSERT
    ON MSP_36.M2_USER_ALERT
    REFERENCING NEW AS NEW OLD AS OLD
    FOR EACH ROW
    DECLARE
    ex_not_valid_role_name EXCEPTION;
    /* Variables */
    nAlertTypeId M2_USER_ALERT.alert_type%TYPE;
    isLogical      boolean;
    validRole     boolean;
    nRole_id      M2_ROLE.role_id%TYPE;
    PRAGMA AUTONOMOUS_TRANSACTION;
    BEGIN
         BEGIN
              SELECT distinct at.alert_type INTO nAlertTypeId
              FROM M2_USER_ALERT ua, M2_ALERT_TYPE at,M2_ALERT_TYPE_PROPERTIES atp
              WHERE ua.alert_type = at.alert_type
              AND at.alert_type = atp.ALERT_TYPE_ID
              AND ua.alert_type = :NEW.alert_type
              AND upper(atp.property_name) = 'LOGICAL'
              AND upper(atp.property_value) = 'TRUE';
              isLogical := true;
         EXCEPTION
                   WHEN no_data_found THEN
                   isLogical := false;
                   NULL;     
         END;     
    IF (isLogical = true) THEN
    BEGIN
              SELECT distinct ro.role_id INTO nRole_id
              FROM M2_ROLE ro, M2_USER_ALERT
              WHERE ro.name = :NEW.name;
         EXCEPTION
                   WHEN no_data_found THEN
                        validRole :=false;
                        RAISE_APPLICATION_ERROR(-20001,'LOGICAL UserAlert: Role with id'|| nRole_id || ' does not exist.');     
                        NULL;
         END;
         validRole := true;
         IF (isLogical = true AND validRole = true AND :NEW.status = 1) THEN
         INSERT INTO M2_USER_ROLE (user_id,role_id)
         VALUES (:NEW.user_id,nRole_id);
         :NEW.role_id := nRole_id;
    END IF;
    END IF;
    commit;
    END;
    Many thanks,
    Michael

    I only get a empty column that include now data. The first insert is working correct so I know that the role_id is valid and working. Can there be problem with commit or my AUTONOMOUS_TRANSACTION running this from JDBC ?
    EXAMPLE data from
    M2_USER_ROLE
    ===================
    USER_ID = ROLE_ID =
    ===================
    20 = 10040 =
    1259756 = 10040 =
    ===================
    Example partly data from
    M2_USER_ALERT
    =========================================================
    USERALERT_ID = USER_ID = ALERT_TYPE = NAME = ROLE_ID =
    =========================================================
    3725 = 1259756 = 10288 = MG_Test = =
    =========================================================
    When inserted from the application the role_id is empty and I've taken the same SQL from the library cache and run it with same BIND variables and then it's working.
    Michael

  • Tree table is not reflecting the updated model data changes at the front end

    I have two tables ,
    1) Provider table(tree table)  2)member table
    I have implemented drag and drop functionality using jQuery UI on both tables.
    In my scenario when I drag a member from the member table and drop it on the Provider table and also when I delete an assigned member from the provider table I will update the data fetched from odata model and again I will call the method which binds the data to the provider table so that the table will reflect the changes.
    here is the code,
    on drop:
    $("#Provider tbody tr").droppable({
      drop: function(event){
           oController.AssignMember(oProviderId, oMemberId)
      }).disableSelection();
    Assign member function:   here am updating the model.
    AssignMember : function(oProviderId, oMemberId){
      var oModel = new sap.ui.model.odata.ODataModel("../../../services/provider.xsodata/", true);
      var oParameters = {};
      oParameters.PROVIDER_ID = oProviderId;
      oParameters.MEMBER_ID = oMemberId;
      oParameters.CREATED_ON = new Date();
      oModel.setHeaders({"content-type" : "application/json;charset=utf-8"});
      oModel.create( "/PROVIDERMEMBERS", oParameters, null, function() {
      var oController = sap.ui.controller("adsm.provider.member_assignment_view");
      oController.GetProviderData();
      },function(jqXHR) {
      var errorMessage = jqXHR.response.body;
      var jsondata = JSON.parse(errorMessage);
      sap.ui.commons.MessageBox.alert(jsondata.error.message.value);
    GetProviderData function: here i bind the data to the table
    GetProviderData: function(){
    var oModel = new sap.ui.model.odata.ODataModel("../../../services/provider.xsodata/", true);
    var Context = "/PROVIDERS?expand=ASSIGNEDMEMBERS&$select=NAME,ID,ASSIGNEDMEMBERS/NAME,ASSIGNEDMEMBERS/ID,ASSIGNEDMEMBERS/PROVIDER_ID";
      var oTable = sap.ui.getCore().byId("tblProviders");
      oModel.read(Context, null, null, true, onSuccess, onError);
      function onSuccess(oEventdata){
      var outputJson = {};
      var p = 0;
      var r = {};
      if (oEventdata) {
      r = oEventdata;
      try {
      if (oEventdata.d){
      r = oEventdata.d;
      } catch(e){
      //alert('oEventdata.d failed');
      try {
      if (oEventdata.d.results){
      r = oEventdata.d.results;
      } catch(e){
      //alert('oEventdata.d.results failed');
      try {
      if (oEventdata.results){
      r = oEventdata.results;
      } catch(e){
      //alert('oEventdata.results failed');
      $.each(r, function(i, j) {
      outputJson[p] = {};
      outputJson[p]["NAME"] = j.NAME;
      outputJson[p]["ID"] = j.ID;
      outputJson[p]["PROVIDER_ID"] = j.ID;
      outputJson[p]["DELETE"] = 0;
      var m = 0;
      if (j.ASSIGNEDMEMBERS.results.length > 0) {
      $.each(j.ASSIGNEDMEMBERS.results, function(a,b) {
      outputJson[p][m] = { NAME: b.NAME,
      ID : b.ID,
      PROVIDER_ID: b.PROVIDER_ID,
      DELETE: 1};
      m++;
      p++;
    var oModel = new sap.ui.model.json.JSONModel();
      oModel.setData(outputJson);
      oTable.setModel(oModel);
      function onError(oEvent){
      console.log("Error on Provider Members");
    oTable.bindRows({
      path:"/"
    Its working fine in chrome but in IE the model data gets updated but the table is not reflecting the changes at front end.Can anyone suggest me a possible solution to fix this?
    Please have a look at the attached screen shots.
    Best regards,
    Amala Suganya.

    Hi Amala,
    I think this will help you:
    Disabling Cache for CRUD/FI OData scenarios for a UI5 Application on Internet Explorer
    Kind regards,
    RW

  • Will apple fix or replace my iphone 4 as the lock button is stuck and its a minor hardware issue ? Also if it was to be a replacement would it be a newer model as apple do not stock the 4 anymore ?

    Will apple fix or replace my iphone 4 as the lock button is stuck and its a minor hardware issue ? Also if it was to be a replacement would it be a newer model as apple do not stock the 4 anymore ?

    If your iPod Touch, iPhone, or iPad is Broken
    Apple does not fix iDevices. Instead, they exchange yours for a refurbished or new replacement depending upon the age of your device and refurbished inventories. On rare occasions when there are no longer refurbished units for your older model, they may replace it with the next newer model.
    ATTN: Beginning July 2013 Apple Stores are now equipped to do screen repairs/replacements in-house on iPhone 5s. In some cases while you wait. According to Apple this is the beginning of equipping Apple Stores with the resources needed to do most repairs for iPhones, iPads, and iPod Touches that would not require major replacements. Later in the year the services may be extended as Apple Stores become equipped and staffed with the proper repair expertise. So, if you need a screen repaired or a broken screen replaced or have your stuck Home button fixed, call your local Apple Store to see if they are now doing these in-house.
    You may take your device to an Apple retailer for help or you may call Customer Service and arrange to send your device to Apple:
    Apple Store Customer Service at 1-800-676-2775 or visit online Help for more information.
    To contact product and tech support: Contacting Apple for support and service - this includes international calling numbers.
    iPod Service Support and Costs
    iPhone Service Support and Costs
    iPad Service Support and Costs
    There are third-party firms that do repairs on iDevices, and there are places where you can order parts to DIY if you feel up to the task:
    1. iResq or Google for others.
    2. Buy and replace screen yourself: iFixit

  • Cost Planning Details not reflecting in new version

    Dear Experts,
                        .  We created the 'NEW' version . But we want to copy cost planning from u201C0u201D version to u201C1u201D version. For
    this we are executing u201CCJ9BSu201D t-code but after executing this, only cost
    are getting copied. Detail Planning is not getting copied.Kindly look into the matter and helpful solutions are

    Dear Experts,
    . We created the 'NEW' version . But we want to copy cost planning from u201C0u201D version to u201C1u201D version. For
    this we are executing u201CCJ9BSu201D t-code but after executing this, only cost
    are getting copied. Detail Planning is not getting copied.Kindly look into the matter and helpful solutions are.
    i.e
    1 I planned material costs in .Cj40 > Primary Cost > Edit >Detailed Planning >Change
       Here we maintain material cost, service cost, BPO etc
    2.When we copy the version from '0' to new version which i have created copying the 1 version.Or say '0' version to '1' version then material cost is not reflecting in new version cost planning after CJ9BS.

  • Laptop does not detect the new HDD

    Good afternoon ladies and gentlemen Gameday! I need help.
    On my laptop broke down the hard drive. According to reports, a lot of bad sectors, SMART. Decided to put a new HDD. Laptop does not see the new hard drive. In the BOOT MENU new hard drive is not detected.
    Old hard drive while still runs in the BOOT menu displays all 3 sections. On the new disk interface is similar to the interface connection on the old disk.
    laptop model: 15-e 051 sr.
    OS: Win 8
    manufacturer of the old hard drive : Hitachi
    new hard drive: seagate.
    New hard drive on another system checked for operability.
    Also, the laptop refused to work with other hard drives: Samsung, Hitachi.
    I am sorry for your Books English. For transfers using Google translator.
    I look forward to qualified support, despite the language barrier.
    Sincerely Sqwosh.

    Hi @sqwosh ,
    Thank you for your query, I will do my utmost to assist you.
    First I would like to let you know that the broken English is not a problem.  I understand that Google translation can be a a little rough in the translations.  We  will work together and I am  sure we will do fine!
    I grasp that you are trying to replace the hard drive but it is not being recognized in the bios.
    Here is a link to the HP Pavilion 15 Notebook PC Maintenance and Service Guide. please note page 57 for a list of supported hard drives.  It will also provide information on removal and replacement of the hard drive.
    You could also try this.
    Once you have the hard installed and connected and you are at the bios screen, you will notice an option to restore defaults along the bottom. ( I believe it is F5) .  This will cause it to scan for the hardware and hopefully find your new hard drive.
    Please do not hesitate to respond if you require further assistance and good luck!
    Sparkles1
    I work on behalf of HP
    Please click “Accept as Solution ” if you feel my post solved your issue, it will help others find the solution.
    Click the “Kudos, Thumbs Up" on the bottom right to say “Thanks” for helping!

  • ADF UI is not reflect the ADF view updated values.

    Hi Expert,
    I have a ADF fusion web application using the ADF-BC. In that one of the View is created using the SQL query (refer the database base view in the back ground). I have some operation in the model layer. The operation updated the records so the view reeds be refresh to get the new values. Unfortunately the values are not refreshed even i ppr the view UI table. I checked in the model by adding some log and the values are correct in the model. So how can i push back the updated values to the UI.
    Please guide me on this.
    - t

    Hi,
    if you change the data through ADF then a PPR refresh will do. If you change the data underneath (which sounds like you are doing), you will need to re-execute the iterator (just use the Execute operationof the view Object in the data control), wich can be done programmatically and declaratively
    Frank

  • The Jtree is not refreshing with new values when mouse click on the node

    hi ,
    I am creating a tree from a vector .The values in the vector is coming from the JTable data after satisfing the some condition. But the data in the Jtable is changing time to time so the data in the vector is also changing .
    But the problem is that when first I create a tree with that data the tree is created but for the next time I click on the tree node the tree is not changing i.e. it is not created with the new values that is stored in the vector at that time .what to do .Please help
    I am using DefaultMutableTreeNode for creating the tree .In starting I have created one root and the one it's child .Now the next subtree of the root child have to be created by this vector data. this subtree should be updated according to the values in the vecter.
    public void valueChanged(TreeSelectionEvent e) {
    //code here
    subtreecreat();
    //some function that create tree after cheching the some condition here
    subtreecreat() {
    Enumeration en=vector.elements();
    while(en.hasMoreElements())
    DefaultMutableTreeNode servername = new DefaultMutableTreeNode(en.nextElement());
    node.add(servername);
    Please help it is very urgent
    Thanks in Advance,
    anum

    Well, you can either use a custom TreeModel that tracks your Vector, or you can use a DefaultTreeModel and call model.reload(node) to refresh the tree below the specified node.

  • Can not see the new appending fields in RSA6

    Hi,
    I add one appending structure to existing datasource, after that I can not see the new field in RSA6, RSO2. However I can see it from RSA2 and SE11 (for extract structure).
    Any idea?
    Thanks
    Victor

    Victor,
    can you tell me how u have done this. you have a DS in RSA6 created from RSO2. then you created a append structure right? then click on your DS on the RSA6 screen. click on change icon on the application tool bar or function key CTRL + SHIFT +F1, maintain the datasource.
    can you able to see the fields here or not (i'm asking for change mode)?
    Nagesh.

  • I can not dowload the new updated software for my Ipod touch 4G. When i do I get an error message that says Network connection has timed out. I have done the trouble shooting steps. Downloaded the latest version of Itunes, and checked network connection

    I can not dowload the new updated software for my Ipod touch 4G. When i do I get an error message that says Network connection has timed out. I have done the trouble shooting steps. Downloaded the latest version of Itunes, and checked network connection

    Disabling the computer's antivirus and firewall during the download and update usually resolves the timeout error.

  • My Numbers program changed yesterday while I was working on a document and now I can't open it.  I get a message telling me I need a newer version to open the document.  All the others seem to open OK.  I HAVE NOT PURCHASED THE NEW VERSION.  What happened

    OK, this is the first time I have used this so I may not have started correctly, so here goes another try. I opened a Numbers Document and noticed the presentation was different from when I worked it before.  Since there have been a number of auto updates since I had worked in Numbers, I assumed I had an updated program.  I found it hard to figure out so I closed the document and went on to other things.  When I went back to it I found a message saying I needed a newer version of the program to open it.  Fortunately, the document was backed up and when I opened the backup it came in my familiar form.  I have not purchased the new version of Numbers but suspect that is what was using for that brief period yesterday.  Anyone know haw that happened?

    Hi Sailor,
    It is pretty amazing you got a new version without even knowing it.
    In System Preferences > App Store you can turn off the automatic updates by unchecking "Install app updates" as I've done here:
    If you're using Numbers across platforms and displaying dynamic output on the iPad or doing data entry there, you'll be *much* happier with Numbers 3.0 than the old version. If you're doing a lot of traditional printing of heavily formatted documents, the old version is much better.  For most day-to-day uses in between it's a toss-up.  The new version, despite its flaws, is a powerful application that can enhance productivity in ways the old version can't.
    For more on the differences between the two, see the features gained, features lost, and workarounds threads, plus Apple's support document on features to be reintroduced in the coming months .
    SG

  • I Just received the update to iTunes, when I I look at the screen I do not see the normal icons.  When I select movies I do not get the new downloads unless i select the list in the sub file. How do I get backto the old method of seeing and using iTunes??

    I Just received the update to iTunes, when I I look at the screen I do not see the normal icons.  When I select movies I do not get the new downloads unless I select the list in the sub file. How do I get back to the old method of seeing and using iTunes??

    I can tell you that this is some of the absolutely worst customer service I have ever dealt with. I found out from a store employee that when they are really busy with calls, they have third party companies taking overflow calls. One of those companies is Xerox. What can a Xerox call center rep possibly be able to authorize on a Verizon account?  I'm Sure there is a ton of misinformation out there due to this. They don't note the accounts properly or so everyone can see them. I have been transferred before and have asked if they work for Verizon or a third party also and was refused an answer so, apparently they aren't required to disclose that information. I spent a long time in the store on my last visit and it's not just customers that get the runaround. It happens to the store employees as well and it's beyond frustrating.

  • I just updated my iTunes and I do not like the newer version.....can I go back to the earlier version??  This new version does not have the iTunes DJ nor does is show at the bottom as in the earlier version how many songs and the size of my library.

    I just updated my iTunes on 12-7-2012 and I do not like the newer version.....can I go back to the earlier version??  This new version does not have the iTunes DJ nor does is show at the bottom as in the earlier version how many songs and the size of my library.

    To do this in iMovie 11. use the SHARE menu. Share your project using the Share menu and choose Export Using QuickTime.
    In the Dialog box that comes up, choose Sound to AIFF, or one of the other sound options. This will create a file that you can drag into iTubes.

  • Could not complete the new 3D extrusion from selected layer command because the path is too complex.

    I was trying to do a photo of mine like in this video but its not working help needed. thanks.
    http://www.youtube.com/watch?v=egyLY78H7nE
    When I tried the 3D I got an error message that said (could not complete the new 3D extrusion from selected layer command because the path is too complex.) what does this mean and how can i fix it?

    There was a bug at one time where really simple paths (like a triangle, for example) could cause that error.
    Is your path really simple (I don't plan to go watch the video)?  If so, have you installed the latest update for Photoshop?  That bug may have been fixed already.
    If it's not that, it's possible that if your path is really complex and simply exceeding Photoshop's capability.
    -Noel

Maybe you are looking for

  • Removing an object from a photo in PSE 10

    I have a photo where there is a bucket sitting on the sidewalk.  I cant seem to get rid of the bucket in this picture.  I have looked for a tutorial but theyare either from a different version of PSE or they are for taking an object out of one pictur

  • Problems with Stack 27 for Solution Manager

    We are trying to install the stack 27 ,on Solution Manager based on Nw 701, but despite we downloaded all the packages listed with the MOPZ  the SPAM transaction continue to arise consistency problems with the queue. The package affected seems to be

  • Import data to spatial from another resoucres?

    Hi all! can anybody help me how to import data to oracle spatial from another resoucre such as : google map, bing...? thanks Edited by: OBIEE.vn on Dec 3, 2010 8:24 PM

  • Issue with clearing previous record while uploading through LSMW

    Hi friends, I have created lsmw for hiring action using transaction PA40. i have a tab delimited flat file, when i run the lsmw script the first record is uploaded perfectly. However the upload halts for the second record, coz the previous record sti

  • How to Enter Multipe Orders & Lines on a Selection Screen?

    Hi, I have a situation where the user wants a report on sales order items. However to choose the specific order lines via the selection screen and run the report for that selection of orders and lines e.g. On the selection screen the following are en