I am having some trouble getting the name for a toolBar component.
I create a jtoolBar as a separate class and instant it in a JinternalFrame. In the JinternalFrame I need to get its components and add a listener to each component. The code I am using is this:
Component toolBarComp[] = jToolBar.getComponents();
for(int i = 1; i < toolBarComp.length; i++)
System.out.println(toolBarComp.getName());
However when I print the getName method all the names are null. I do set the name for the components in the tool bar class and I can get them to print from the class. But using the getComponents() I cannot get the name to display.
Any ideas as to what I could be doing wrong? Or is there a better way of doing this.
Thanks in advance
Jeff
I create a jtoolBar as a separate class and instant it in a JinternalFrame. In the JinternalFrame I need to get its components and add a listener to each component. The code I am using is this:
Component toolBarComp[] = jToolBar.getComponents();
for(int i = 1; i < toolBarComp.length; i++)
System.out.println(toolBarComp.getName());
However when I print the getName method all the names are null. I do set the name for the components in the tool bar class and I can get them to print from the class. But using the getComponents() I cannot get the name to display.
Any ideas as to what I could be doing wrong? Or is there a better way of doing this.
Thanks in advance
Jeff