The Java Developers Almanac 1.4


Order this book from Amazon.

   
Home > List of Packages > javax.swing  [141 examples] > JSlider  [7 examples]

e796. Setting the Orientation of a JSlider Component

Besides being either horizontal or vertical, a slider can also be inverted. An inverted horizontal slider moves from right-to-left. An inverted vertical slider moves from top-to-bottom.
    // Create a horizontal slider that moves left-to-right
    JSlider slider = new JSlider();
    
    // Make the horizontal slider move right-to-left
    slider.setInverted(true);
    
    // Make it vertical and move bottom-to-top
    slider.setOrientation(JSlider.VERTICAL);
    slider.setInverted(false);
    
    // Make it vertical and move top-to-bottom
    slider.setOrientation(JSlider.VERTICAL);
    slider.setInverted(true);

 Related Examples
e794. Creating a JSlider Component
e795. Getting and Setting the Values of a JSlider Component
e797. Showing Tick Marks on a JSlider Component
e798. Showing Tick-Mark Labels on a JSlider Component
e799. Constraining JSlider Component Values to Tick Marks
e800. Listening for Value Changes in a JSlider Component

See also: Actions    JButton    JCheckBox    JComboBox    JDesktop and JInternalFrame    JFrame, JWindow, JDialog    JLabel    JList    JProgressBar    JRadioButton    JScrollPane    JSpinner    JSplitPane    JTabbedPane    JToolBar    Keystrokes and Input Maps    Layout    Look and Feel    Menus    Progress Monitor    The Screen    Tool Tips    UI Default Values   


© 2002 Addison-Wesley.