Reproduced Java Swing JScrollPane (scroll panel) how to use

Source: Internet
Author: User

1 /**2 * Java Swing's jscrollpane panel3 * When setting up the interface, you may experience the display of a larger portion of the content in a smaller container form, which you can use4 * jscrollpane Panel, jscrollpane panel is a panel with scroll bars, is also a container, but often used to decorate a single5 * control, and you cannot use the layout manager. If you need to place multiple controls in the JScrollPane panel, you need to add multiple6 * Control is placed on the JPanel panel, and the JPanel panel is added to the JScrollPane control as a whole control. 7 * 8 * @authorGao9 */Ten  PackageCom.gao; One  A Importjava.awt.BorderLayout; -  - ImportJavax.swing.JFrame; the ImportJavax.swing.JPanel; - ImportJavax.swing.JScrollPane; - ImportJavax.swing.JTextArea; - ImportJavax.swing.border.EmptyBorder; +  -  Public classJscrollpanedemoextendsjframe{ +    PrivateJPanel ContentPane; A    PrivateJScrollPane ScrollPane; at    PrivateJTextArea TextArea;
-   PublicJscrollpanedemo () { -Contentpane=NewJPanel (); -Contentpane.setborder (NewEmptyborder (5,5,5,5)); -Contentpane.setlayout (NewBorderLayout (0,0)); - This. Setcontentpane (ContentPane); inScrollpane=NewJScrollPane (); - Contentpane.add (scrollpane,borderlayout.center); toTextarea=NewJTextArea (); +    //Scrollpane.add (TextArea); - Scrollpane.setviewportview (TextArea); the    This. Settitle ("Scroll panel use"); *    This. Setdefaultcloseoperation (jframe.exit_on_close); $    This. setbounds (100, 100, 250, 200);Panax Notoginseng    This. setvisible (true); - } the Public Static voidMain (String []args) { +Jscrollpanedemo example=NewJscrollpanedemo (); A    } the}

Reproduced Java Swing JScrollPane (scroll panel) how to use

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.