File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes Changing the values in the list box Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Changing the values in the list box" Watch "Changing the values in the list box" New topic

Changing the values in the list box

Anant Rao
Ranch Hand

Joined: Nov 12, 2004
Posts: 126

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,
Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24199

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.

[Jess in Action][AskingGoodQuestions]
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
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

Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
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.


Java API Documentation
The Java Tutorial
I agree. Here's the link:
subject: Changing the values in the list box
It's not a secret anymore!