• 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

How can I set the window according to checkboxes number?

 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a JFrame where I created dynamically checkboxes and add them to a JPane. Here is the code:

     

Only 10 checkboxes can be seen on the screen. I should somehow set the window according to the number of checkboxes. I tried to use JScrollPane with following modifications:
 
and

Unfortunately, it did not help because the frame contains a button as well which will set the selected values and the JScrollePane did not contain the button.
Could someone suggest me a solution?

 
Bartender
Posts: 5465
212
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi Beate,

I see all the checkboxes in the following code:


 
Beata Szabo-Takacs
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear Piet,
Thank you for your comment! Finally, I found another way to solve this issue.
I added the JButton to JPanel and a JScrollPane was used with JPanel. Moreover, I also created a
vertical box column based on https://www.tutorialspoint.com/how-to-create-vertical-button-column-with-gridlayout-in-java
Here is my code:


 
reply
    Bookmark Topic Watch Topic
  • New Topic