Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: set the slider's models (range)

  1. #1
    Java kindergarten chronoz13's Avatar
    Join Date
    Mar 2009
    Location
    Philippines
    Posts
    666
    Thanks
    177
    Thanked 30 Times in 28 Posts

    Default set the slider's models (range)

    i want to set the slider's arrrow in 100.. how can i do that?

    public class NewClass {
     
        public static void setComponents(Container cont) {
     
            JSlider slider = new JSlider(100, 500);
     
            slider.setBounds(50, 50, 300, 50);
            slider.setMinorTickSpacing(10);
            slider.setMajorTickSpacing(100);
            slider.setPaintTicks(true);
            slider.setPaintLabels(true);
     
            cont.setLayout(null);
            cont.add(slider);
        }
     
        public static void showTheWindow() {
     
            JFrame frame = new JFrame();
     
            setComponents(frame.getContentPane());
     
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.setSize(400, 200);
            frame.setVisible(true);
        }
     
        public static void main(String[] args) {
     
            SwingUtilities.invokeLater(new Runnable() {
     
                public void run() {
     
                    showTheWindow();
                }
            });
     
        }
    }

    tnx in advance!


  2. #2
    Java kindergarten chronoz13's Avatar
    Join Date
    Mar 2009
    Location
    Philippines
    Posts
    666
    Thanks
    177
    Thanked 30 Times in 28 Posts

    Default Re: set the slider's models (range)

    solved


    JSlider slider = new JSlider (100, 500, 100)

    where the third value which is "100", will be the value where the slider's arrow is initialized

    hahahaha