java如何拿到jpanel中的jtextfield这个组件,不是里面的内容
http://www.educity.cn/wenda/367417.html
将JTextField设置成静态的?然后类名.JTextField?
通过传参的方式得到
JPanel panel = new JPanel();
int count = panel.getComponentCount();
for (int i = 0; i < count; i++) {
Component comp = panel.getComponent(i);
if(comp instanceof JButton){
JButton btn = (JButton)comp;
btn.setEnabled(false);
}
if(comp instanceof JTextField){
}
}