Solved

JPanel selecting multiple item from list

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
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…
The viewer will learn how to implement Singleton Design Pattern in Java.

733 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