This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Svelte and Sapper in Action and have Mark Volkmann on-line!
See this thread for details.
Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Changing the values in the list box

 
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

There are two list box one with
listBox A (2001 English
20002 Maths....)
listBox B (1,2004 French
2,3002 Greek
3,2003 Italian)

Now i want to move data from listBox B to A by removing the content before comma and comma.( that I finished with substring and moving is also done)

Now the problem is suppose if i move Greek from listBox B to A the contents in ListBox B should change such way that
ListBox B(1,2004 French
2,2003 Italian)

i.e the value before comma should change ...
new option adds a new element but how to modify the existing element.

Its kind of urgent

Any help is appreciated,
Infyniti.
 
author and iconoclast
Posts: 24203
43
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You may not have read our naming policy on the way in. It requires that you use a full, real (sounding) first and last name for your display name. A single name, a joke name, or a "handle" won't work here. You can change your display name here. Thanks for your cooperation.

Note that many people at the Ranch won't answer your questions until you comply.
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
assuming the name is now OK, this might be what you're trying to do.
double click any item in the list - the item will be removed, and the
'lower' items re-numbered

 
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I understand correctly, you want the numbering to change so that the items are numbered in increasing order without skipping any numbers when an item is removed. I assume that your "list box" is either a JList or a List. In either case, I think you should create a class that implements ListModel. This class can be responsible for ensuring that the number in front of the rest of the label is correct.

If you are using JComboBox instead, you should implement ComboBoxModel. In either case, the API provides an abstract model that implements many of the details that are often the same between different models. Check out the Java Tutorial for more details on how this works.

Layne
 
It would give a normal human mental abilities to rival mine. To think it is just a tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic