• Post Reply Bookmark Topic Watch Topic
  • New Topic

Linking the JCheckBox with JScrollBar  RSS feed

 
Vaskar Dasgupta
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • 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.
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
Vinod Venugopal
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
  • 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
 
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!