• 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

Linking the JCheckBox with JScrollBar

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a JPanel on which 15 JCheckBoxes have been put. I want to put a vertical and horizontal JScrollBar so that i can scroll to the 15th JCheckBox. having 15 check boxes otherwise makes the window too bag. Sample code will be appreciated. I am desperately in need of this code snippet as early as possible.
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just create a JScrollPane that contains your JPanel... it's that simple...

-Nate
 
Vaskar Dasgupta
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Nathan, I had done that (putting the JCheckBoxes in the JPanel and then the JPanel in the JScrollPane) but the scroll pane doesnt show up. FYI I am not setting any layout for the JPanel in the JScrollPane.
Waiting for your reponse. Thanks in advance.
 
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
Give some size to the ScrollPane using
setPreferredSize(new Dimension(int,int));
or else you could in the JScrollPane constructor itself specify whether you always want a vertical / horizontal scrollbar.
Vinod
 
reply
    Bookmark Topic Watch Topic
  • New Topic