Skip to main content
GameDev.net gamedev.net
🔒 Locked

[java] using slider

Started by joeyg2477 Apr 3, 2006 at 12:35 PM 2 replies 650+ views
Original Post
joeyg2477
joeyg2477
im trying to implement a slider on a jframe and it's taking up the whole window. I've searched for information on it, but I can't find the imformation I need. So, how can I add a jslider to a jframe that only takes up a little space on the side of the window?
Son of Cain
Son of Cain
The reason why it takes the whole window space is because of the Layout manager used. You should specify a (GridBag) layout manager to order your components and place them where you want them to be.

I'm fond of using a null layout manager - frame.getContentPane().setLayout(null) - and placing the components using X, Y, Width and Height. That keeps their position to where you want them, but the drawback is when you want to resize the window - which I usually disable when appropriate.

Son Of Cain
a.k.a javabeats at yahoo.ca
Son of Cain
Son of Cain
JFrame frame = new JFrame();JSlider slider = new JSlider();frame.getContentPane().setLayout( null );frame.getContentPane().add( slider );slider.setBounds(0, 0, 100, 50);
a.k.a javabeats at yahoo.ca

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.