Solved

JPanel selecting multiple item from list

Posted on 2006-06-26
4
269 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
  • 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
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…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

776 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