简体   繁体   English

选择“选项卡”时执行操作

[英]Performing an action when the “tab” is selected

I am creating a JDBC application, which the user interface consists of 2 tabs. 我正在创建一个JDBC应用程序,用户界面由2个选项卡组成。 First tab is to insert data, second is to update. 第一个选项卡是插入数据,第二个是更新。 When the user click on the second tab, I need to execute the method "getUpdates()". 当用户单击第二个选项卡时,我需要执行方法“getUpdates()”。 I need to execute this method each time that the user navigates to this second tab. 每次用户导航到第二个选项卡时,我都需要执行此方法。 How can I do it? 我该怎么做?

(For more information, these two tabs are separate Java beans, which extends the class "Common GUI". "Common GUI" extends from JPanel. They get displayed in class "Main GUI", as tabs) (有关更多信息,这两个选项卡是单独的Java bean,它扩展了“Common GUI”类。“Common GUI”从JPanel扩展。它们显示在类“Main GUI”中,作为选项卡)

Please help! 请帮忙!

如果您使用的是JTabbedPane那么可以使用JTabbedPane#addChangeListener如本例所示

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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