识别jtabbedPane中jTextPane的选定对象 [英] Identify Selected Object of jTextPane inside jtabbedPane

查看:69
本文介绍了识别jtabbedPane中jTextPane的选定对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用JtabbedPane,其中包含几个jTextPanes,例如jTextPane1,lTextPane2 ...等.现在,我想在选择特殊选项卡期间执行一些操作.例如:如果我选择jTextPane 2,我想启用一个按钮.现在,我能够识别Tab.ie的选定组件:jTextPane.但是我无法识别选择了哪个jTextPane(jTextPane的哪个对象).如何解决..?谁能帮我? plz ..

I am using JtabbedPane which contains several jTextPanes like jTextPane1,lTextPane2...etc. NOw I want to perform some actions during the selection of a partiular tab. eg: I want to enable a button if I select jTextPane 2.. Now I am able to identify selected Component of Tab.ie: jTextPane. But I am not able to identify which jTextPane is selected(Which object of jTextPane).. How can I resolve it ..? Can any one help me? plz..

推荐答案

看看复选框和单选按钮"中给出的代码.添加了一个动作侦听器,该侦听器遍历所有组件并搜索选定的组件.您可以使用该代码来实现.

http://oreilly.com/catalog/learnjava/chapter/ch14.html [ ^ ]

另外,另一种方法是为每个组件实现一个动作侦听器,以处理组件被选中的事件.

祝你好运!
Have a look at the code given at "Checkboxes and Radio Buttons". An action listener is added that traverses all components and searches for the one selected. You can use that code to do it.

http://oreilly.com/catalog/learnjava/chapter/ch14.html[^]

Also, another way would be to implement an action listener for each component to handle the event of a component getting selected.

Good luck!


这篇关于识别jtabbedPane中jTextPane的选定对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆