• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 307
  • Last Modified:

JPanel selecting multiple item from list

Started a new job and they have a application which is gui based and has two seperate list and they want me to change the code to select multiple items from one list and then point them to the one item from the other list.  So for example

                          Before                     After
List A                   List B                      List B
A                         1                            1
B                         2                            2
C                         3                            2
D                         4                            2
E                         5                            5
F                         6                            6
G                         7                            7

Then through the gui the user would click ctrl and another key and select maybe BCD  from list A and point them all to a item from list B for the number 2.   Then next time user sees the list it would the reflect the After List B view

Havent done this is years and I mean years....

Looks like both list are created on object called JPanel which uses a layout manager.  Also they have a event listener so to speak.

Does anyone have a example of this where multiple items are selected from a list box using JPanel and them pointing them to another single item on another list?
0
TheVeee
Asked:
TheVeee
  • 2
2 Solutions
 
TheVeeeAuthor Commented:
Just an update, I now have it selecting more rows because it uses the ListSelectionMode and I found that all I had to do is select mutiple option vice single.  So what IM really looking for is a example now of how to parse it and a really good tutorial or book recommendation for someone to get up to speed on JPanel, Swing and and using the functionallity of the packages:

import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.ListSelectionModel;
0
 
JavatmCommented:
On the itemlistener add the values you need.
0
 
girionisCommented:
Have a look here: http://javaalmanac.com/egs/javax.swing/pkg.html for information on how to use several swing components. Actualyl it would be very simple what you are trying to do once you are able to get the selections of both lists. Look here: http://javaalmanac.com/egs/javax.swing/list_ListGetSel.html how to get the selected items. Then the only thing you have to do is to get the position of the items in the first list (e.g. first, second and forth item), the value of the second list (e.g. "2") and then just change the values in the list B in the corresponding positions. I guess the values of the list B are stored somewhere, in an array or a vector. Reload the list and that should be it.
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now