• Post Reply Bookmark Topic Watch Topic
  • New Topic

Displaying a randomised list

 
Justin Grace
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I am trying to generate a list of 10 items of 2 types. e.g. {Y,Y,N,Y,N,N,Y,N,N,Y}
I am currently doing this by generating a string and pseudorandomising it.
I then want to display this list in a JFrame. I have been doing this by using a HTML list function passed through Java however this no longer meets my needs.

What is the best way to display this list using Java? I want to list these items vertically, and be able to insert breaks (empty items) at certain points (i.e. every 2nd item, every 5th item). What is the best way to approach this problem?

Thanks,

Justin
 
Greg Charles
Sheriff
Posts: 3012
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's been awhile since I've used Swing, but JList is the Swing list component.
 
Campbell Ritchie
Marshal
Posts: 53225
124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

The advice you have been given looks good to me; this Java™ Tutorials page may help, too.

Moving thread to our GUI forum.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!