Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6752789
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:05:09+00:00 2026-05-26T13:05:09+00:00

I have a simple slide program, and left side of my application, there is

  • 0

I have a simple slide program, and left side of my application, there is a JList which shows the slides on the current application. I can save and load the slides. The problem is, when I’m trying to load the slides from XML file, I cannot delete all items, in the JList, and add them. Because when I remove elements by model.removeAllElements(); and then trying to add items by;

    for(int i=0; i<mL.size(); i++){
        model.add(i, "Slide No: " + i);
        slideCounter++;
    }

Then valueChanged function will be called, and because I’m getting elements from arrayList in that function, it gives ArrayIndexOutOfBoundsException

Therefore, in my load method, I create a new empty list(dMode), then I initialize the list with the number of slides by:

    list = new JList(dMode);
    jScrollPane1 = new JScrollPane(list);

but I cant assign new list to the current list.

What is your advice, how should I solve this ?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T13:05:10+00:00Added an answer on May 26, 2026 at 1:05 pm

    I would either implement my own ListModel or I would bind the data to the list using JGoodies Binding. When using JGoodies your view model could fire a PropertyChangeEvent whenever your array contents changes and your view will then be updated automatically. E.g.

    Bindings.bind(myJList, new SelectionInList<String>
        (beanAdapter.getValueModel("listContents"),
         beanAdapter.getValueModel("listSelection")));
    

    with a view model class that has a property for the list contents and one for the current selection.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making a simple drawing program with slides in it and I have an
I have simple SSIS package which reads data from flat file and insert into
I have simple SSIS package in which On Error event handler I have created
Haskell is a pure functional language, which means Haskell functions have no side affects.
I have a relatively simple program where I try establish Client Server connection and
I have a client who is deploying a simple affiliate program. Currently, if a
I am trying to make a simple client-server chat program. On the client side
I have a fairly simple program based largely on a simple bluetooth test client
I have a simple program I'm developing to perform some bandwidth tests on remote
I have written a simple network program on java using sockets. Program has a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.