Reputation: 133
I´m building a swing aplication , which has all visual components runtime created on a single class. Every control shows fine. Any time a component is declared, a component.setName(String);
is placed.
The problem is that when trying to access that names, via component.getName();
, even within the same class instance, I get null result.
for(Component c:this.getFrame().getComponents()) {
System.out.println(c.getName());
}
getFrame
is just an standar getter returning main Jframe.
That just print one null, but frame is populated with components.
Expected result should be f.e. "Calculate" instead of null
Upvotes: 0
Views: 154
Reputation: 133
it´s been a while: I think I have find the way to solve this q, anyway feedback´swelcome. I´m afraid it was my fault, cause i didn´t explained well the problem. The point are containers (readJFrames, JPanel or whatever). If you´ve got a JPanel inside, let´s say a JFrame, you´ll have to call getComponents of that panel, and so on... Hope it solves the q. Thanks anybody who kept on.
Upvotes: 1