• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Prevent Duplicate value from jlist to jlist by way of a jbutton

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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

 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
> 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
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
> 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
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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




100% agree with you! Thanks again for your help.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic