• 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
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

Which Swing component to use ?

 
Ranch Hand
Posts: 384
MyEclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi ranchers ,

I am a creating a swing Gui interface in which a player has to select 6 numbers from the range of 1-50.

Which Swing component would be a good choice ?
 
Ranch Hand
Posts: 177
Hibernate Python Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would use a jformattedtextfield combined with a jslider.
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You need to provide more information to get the best suggestion.

6 numbers together, or one by one?
6 numbers once, or repeatedly?

Prima facie, I would suggest 6 JComboBoxes with the drop-down set to display 10 rows, maybe 15 if placed near the top of a tall enough window to not look out of place. But a JSpinner for each number may be more appropriate, or maybe even six pairs of JSpinners, one for each digit of each number.
 
Ranch Hand
Posts: 4632
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
if this is for some type of lotto (pick 6), 50 x JToggleButton might be the go.

 
Sheriff
Posts: 22701
129
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How about a JList with a ListSelectionModel that only allows 0-6 selected items?
 
naveen yadav
Ranch Hand
Posts: 384
MyEclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Darryl Burke wrote:You need to provide more information to get the best suggestion.

.



i am working on a RMI based Lottery application in which a player, on client side, have to select 6 numbers from the range of 1-50.Once all 6 numbers are selected
these number send to server and those all 6 numbers are matched against a random number generated by the server.

 
Darryl Burke
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Then Michael's suggestion looks to be the best approach.

edit You might want to add logic that disables unselected buttons when 6 are already selected.
 
naveen yadav
Ranch Hand
Posts: 384
MyEclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i am trying the 6 JSpinner but facing a problem .

the problem is when i changes the input field of one JSpinner , the value of input field of all other 5 JSpinner also changes simultaneously .

here is a code



what is the problem here ?
 
Sheriff
Posts: 27454
88
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
They all have the same model.
 
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
you want to select 6 from 50, but using JSpinners all you're doing is
picking 1 from 50 and doing it 6 times. As is, the same number can
be selected 6 times.

some people even pick patterns, not numbers, so JSpinner really is a poor choice.
 
Where does a nanny get ground to air missles? Protect this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic