简体   繁体   中英

How can I refresh a JPanel in a JTabbedPane only if that tab is the one that is visible?

我有一个窗格,我需要重建内容,然后将其与当前面板交换,但前提是它是当前选项卡。

You can simply do this:

final int nTabIndex = myTabbedPane.indexOfTabComponent( myPanel );
final boolean bIsVisible = myTabbedPane.isEnabledAt( nTabIndex );
if ( bIsVisible ) {
    // Do stuff with myPanel
    myPanel.repaint();
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM