Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Multiple Checkbox on Panel  RSS feed

 
charuta parth
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hello All Ranchers,

I want to display multiple checkbox on panel, and number of checkbox will be decided runtime.

How to place all in right format without distorting panel size?

Appriciate your help,

Thanks
 
Rob Spoor
Sheriff
Posts: 21092
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check out http://java.sun.com/docs/books/tutorial/uiswing/layout/using.html
 
Fred Hamilton
Ranch Hand
Posts: 684
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's not easy to find clearcut info about adding swing components dynamically at runtime, especially if the programmer is not sure how many will be added.

In addition to what Rob provided, this link provides a few insights

http://forums.sun.com/thread.jspa?threadID=5365701
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
assuming your checkboxes are vertical, 2 layouts would do the job
1) BoxLayout, or
2) GridLayout(0,1), but this would need to be wrapped in another JPanel, to take up any additional space
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!