Solved

JPanel selecting multiple item from list

Posted on 2006-06-26
4
295 Views
Last Modified: 2010-03-31
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
Comment
Question by:TheVeee
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 5

Author Comment

by:TheVeee
ID: 16987860
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
 
LVL 15

Assisted Solution

by:Javatm
Javatm earned 150 total points
ID: 16988017
0
 
LVL 15

Expert Comment

by:Javatm
ID: 16988071
On the itemlistener add the values you need.
0
 
LVL 35

Accepted Solution

by:
girionis earned 350 total points
ID: 16990505
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

729 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question