Construct the GUI for the slider

The code in Listing 3

Although the code in Listing 3 is a little tedious,

Listing 3. Construct the GUI for the slider.
    //Construct the GUI for the slider.
    slider.setMajorTickSpacing(60);
    slider.setMinorTickSpacing(15);
    slider.setPaintTicks(true);
    slider.setPaintLabels(true);

    mainPanel.setLayout(new BorderLayout());
    titlePanel.add(new JLabel(
                            "Rotation Angle in Degrees"));
    mainPanel.add(titlePanel,BorderLayout.NORTH);
    mainPanel.add(slider,BorderLayout.CENTER);
    
    getContentPane().add(mainPanel);
    pack();//Adjust the size of the slider GUI.
    
    //Compute an improved size and location for the
    // GUI containing the slider.
    setSize(displayWidth + 2 * getInsets().left,
            mainPanel.getHeight() + slider.getHeight());
    setLocation(0,displayHeight + getInsets().top 
                                + getInsets().bottom + 1);
    setVisible(true);

File: au.htm [Next] [Prev]