开发者

Capturing the close tab event of a JTabbedPanel in Java Swing

开发者 https://www.devze.com 2022-12-13 06:48 出处:网络
Is it possible to capture the close tab event for a JTabbedPanel in Java Swing. 开发者_运维问答

Is it possible to capture the close tab event for a JTabbedPanel in Java Swing.

开发者_运维问答

I want to check for some conditions and if they are not met, then I have to prevent the user from closing it.

Thanks!

Update: I created a custom event, based on this code and it solved my problem.


Sun's tutorial on Tabbed Panes has an example with close buttons on each tab. If you look a the source of the example you can see it reacting to the close clicked.

Edit: ButtonTabComponent. It has an inner class that extends JButton. Based on your comment, do you already have something in place that closes Tabs? What are you doing to achieve this?


I created a custom event, based on this code and it solved my problem.

0

精彩评论

暂无评论...
验证码 换一张
取 消