The Java Developers Almanac 1.4


Order this book from Amazon.

   
Home > List of Packages > javax.swing  [141 examples] > JScrollPane  [3 examples]

e820. Creating a JScrollPane Container

The Swing components do not typically have scroll bars. In order to automatically display scroll bars, you need to wrap the component in a scroll pane.
    // Create a scrollable text area
    JTextArea textArea = new JTextArea();
    JScrollPane scrollableTextArea = new JScrollPane(textArea);
    
    // Create a scrollable list
    JList list = new JList();
    JScrollPane scrollableList = new JScrollPane(list);

 Related Examples
e821. Setting the Scrollbar Policy of a JScrollPane Container
e822. Listening for Scrollbar Value Changes in a JScrollPane Container

See also: Actions    JButton    JCheckBox    JComboBox    JDesktop and JInternalFrame    JFrame, JWindow, JDialog    JLabel    JList    JProgressBar    JRadioButton    JSlider    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.