e839. 使JTabbedPane中的卡片可滚动

By default, all the tabs in a tabbed pane are displayed. When the tabs are wider than the width of the tabbed pane, they are displayed in rows. If space is an issue, it is possible to configure the tabs to appear in a single row along with a scroller that allows the tabs to be scrolled into view.

    // Create a tabbed pane
    JTabbedPane pane = new JTabbedPane();
    
    // Add some tabs...; see e830 向JTabbedPane中加入一个卡片
    // Get the number of rows of tabs
    int rows = pane.getTabRunCount();
    
    // Get the current layout policy
    int policy = pane.getTabLayoutPolicy(); // WRAP_TAB_LAYOUT
    
    // Configure the tabs to scroll
    pane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);

 

Related Examples
posted @ 2018-09-06 09:15  borter  阅读(136)  评论(0编辑  收藏  举报