Link to home
Create AccountLog in
Avatar of sargent240
sargent240Flag for United States of America

asked on

Netbeans, populate a list, add, and delete from a list box

I have two list boxes on a frame created using Netbeans.   One of them is  bound to a database.  I would like to  select one or more items from the populated box, click a button and put a copy of the selected items into the other listbox.  Anyone know of some simple example code or have some guidance as how to accomplish this?  Thank you
Avatar of Bruce Smith
Bruce Smith
Flag of United States of America image

Link to home
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of sargent240


Pat - This is what I ended up doing and it works greate.  Thanks for your help.

I declared private DefaultListModel lm = newDefaultListModel(); with the rest of my declared buttons and textfields etc...

Then I went to the jlist properties
section and clicked on the model section and typed in lm after selecting custom code. and then just added the elements to the add button after creating an event actionperformed by right clicking on the add button, selecting events, then actionperformed and typing in the following code.

lm.addElement(jTextField1.getText()); etc... for the rest of the textfields