如何加载所有控制变量名称,然后编辑它们的属性
how to load all control variable names and then edit their properties
我想为示例加载所有控制变量
按钮1
按钮2
按钮 3
然后像
一样编辑它们的属性
Button1.settext() ;
请告诉我他们有办法做到这一点。
假设您将所有这些标签放在同一帧中,您可以尝试以下操作:
Arrays.asList(myframe.getComponents()).forEach((c) -> {
if( c instanceof JLabel) {
JLabel l = (JLabel)c;
//do whatever you'd like to do with your label here...
}
});
我想为示例加载所有控制变量 按钮1 按钮2 按钮 3
然后像
一样编辑它们的属性Button1.settext() ;
请告诉我他们有办法做到这一点。
假设您将所有这些标签放在同一帧中,您可以尝试以下操作:
Arrays.asList(myframe.getComponents()).forEach((c) -> {
if( c instanceof JLabel) {
JLabel l = (JLabel)c;
//do whatever you'd like to do with your label here...
}
});