I would really appreciate an answer:
I have a few JButtons generated with this:
for(int i = 0; i < buttons.length; i++){
buttons[ i] = new JButton(blank);
if(i == 3 || i == 6){
newLine++;
lineCount = 0;
}
buttons[ i].setBounds(lineCount*150,newLine*150,150,150);
cont.add(buttons[ i]);
buttons[ i].addActionListener(this);
lineCount++;
}
so of course they don’t have global names…
Because of this, I need to know how to take the image “out” of the JButton so I know what kind of button it is or be able to identify buttons by name(?).
So how can I do this? Thanks!
by the way, cont is a java.awt.Container
use
setIcon()andgetIcon()methods to set and get image-icons on JButtonEdit in question, demands edit in answer:
Identification of button is best done with either:
Component.getName()andComponent.setName()orgetText()andsetText().