Re: how to set (preferred) JSlider length?
In article
<363524a4-650b-4cd0-99dd-c46da29bd966@v39g2000pro.googlegroups.com>,
Mark_Galeck <mark_galeck_spam_magnet@yahoo.com> wrote:
[...]
Mark_Galeck wrote:
Nope, same thing as always, slider length is 1024 (covers the
whole applet).
[...]
Sorry, I overlooked the applet requirement, but this seems to work:
import java.awt.*;
import javax.swing.*;
/**
* JSliderTest1
* @author John B. Matthews
*/
public class JSliderTest1 extends JPanel {
public static void main(String args[]) {
JFrame frame = new JFrame("Slider!");
frame.setContentPane(new JSliderTest1());
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(600, 200);
frame.setVisible(true);
}
public JSliderTest1() {
this.setLayout(new BorderLayout());
this.add(new JLabel("West"), BorderLayout.WEST);
this.add(new JLabel("North", JLabel.CENTER), BorderLayout.NORTH);
this.add(genSliderPanel(), BorderLayout.CENTER);
this.add(new JLabel("South", JLabel.CENTER), BorderLayout.SOUTH);
this.add(new JLabel("East"), BorderLayout.EAST);
}
private JPanel genSliderPanel() {
JPanel panel = new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
JSlider slider = new JSlider();
slider.setMaximumSize(new Dimension(400, Short.MAX_VALUE));
panel.add(Box.createVerticalGlue());
panel.add(slider);
panel.add(Box.createVerticalGlue());
return panel;
}
}
--
John B. Matthews
trashgod at gmail dot com
home dot woh dot rr dot com slash jbmatthews