Solved

JPanel selecting multiple item from list

Posted on 2006-06-26
4
250 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
Comment Utility
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
Comment Utility
0
 
LVL 15

Expert Comment

by:Javatm
Comment Utility
On the itemlistener add the values you need.
0
 
LVL 35

Accepted Solution

by:
girionis earned 350 total points
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…

762 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now