Prevent Duplicate value from jlist to jlist by way of a jbutton
William Kohus
Greenhorn
Joined: Feb 19, 2012
Posts: 11
posted
0
Here is what I have so far. Now I just get the "No duplicates please!" message whenever I add anything to lbSelection.
I need to recognize that there is a duplicate and prevent the value from being entered into the list!
Any help you can provide would be greatly appreciated! Thanks!
HERE is the whole program
Michael Dunn
Ranch Hand
Joined: Jun 09, 2003
Posts: 4632
posted
0
do you really need to retain all the teams on the left?
Most similar-concept programs I've seen move the selection from the left to the right (or back),
meaning no possibility of duplicates.
William Kohus
Greenhorn
Joined: Feb 19, 2012
Posts: 11
posted
0
Michael Dunn wrote:do you really need to retain all the teams on the left?
Most similar-concept programs I've seen move the selection from the left to the right (or back),
meaning no possibility of duplicates.
I guess I don't need them but the text box above lbChoices is for a user to enter another team so I think I would need to keep them in the left side list.
Michael Dunn
Ranch Hand
Joined: Jun 09, 2003
Posts: 4632
posted
0
> Here is what I have so far. Now I just get the "No duplicates please!" message whenever I add anything to lbSelection.
OK, this bit looks easily fixable
now it shouldn't 'always' show.
do you still need help on duplicates? or was this all you were after?
William Kohus
Greenhorn
Joined: Feb 19, 2012
Posts: 11
posted
0
Michael Dunn wrote:> Here is what I have so far. Now I just get the "No duplicates please!" message whenever I add anything to lbSelection.
OK, this bit looks easily fixable
now it shouldn't 'always' show.
do you still need help on duplicates? or was this all you were after?
I was hoping that line would prevent my duplicates but it didn't! So yes, still need help preventing duplicates!
Michael Dunn
Ranch Hand
Joined: Jun 09, 2003
Posts: 4632
posted
0
this is just for the add single button
(comment out your old method, in case you need it later)
replace with this
William Kohus
Greenhorn
Joined: Feb 19, 2012
Posts: 11
posted
0
Michael Dunn wrote:this is just for the add single button
(comment out your old method, in case you need it later)
replace with this
Thanks so much! I couldn't stare at it any longer. This also helped me get the add all button working as well! Now if I can just figure out how to add text to the jlist from the jtextfield on a focuslost!
Michael Dunn
Ranch Hand
Joined: Jun 09, 2003
Posts: 4632
posted
0
> Now if I can just figure out how to add text to the jlist from the jtextfield on a focuslost!
really a bad idea (many reasons why accidental loss of focus),
better to add a little 'add' button beside the textfield
William Kohus
Greenhorn
Joined: Feb 19, 2012
Posts: 11
posted
0
Michael Dunn wrote:> Now if I can just figure out how to add text to the jlist from the jtextfield on a focuslost!
really a bad idea (many reasons why accidental loss of focus),
better to add a little 'add' button beside the textfield