hey
um im not sure if this will work but try it
im guessing the reason you want set the name of the Object is so that you can use it in an action performed method yes??
if so then there is a simple maybe a little dangerous way bt that can be fixed, way of getting around the problem
java
public void actionPerformed(ActionEvent evt){
JButton src = (JButton) evt.getSource();//the dangerous line..
//this can be deadly because the evt might not becoming from a button..
//however this can be fixed reallly easily let me know if this is wt u want 2 do
//nd ill show you how 2 make this fool proof
System.out.println(src.getText());
//returns the name of the Button that you gave to the constructor
//this means that you can use it in a if statement eg:
if(src.getText().equals("btn11")){
//do shit here
}
}
what this means is that you can now use the button text instead of the object name. i think this should solve your problem???
but then again i dont understand what you want 2 do..
could you provide an image of the game and maybe an example play???
~~~~~~~~~~~~~~~~~~~
just as a side note... if the reason you dont want 2 use the Button text is because you dont want it to show up in the game then that is an easy fix aswell
we can extend the JButton class, add a constructor value(or just a new method) nd then a way 2 use this new value
This post has been edited by gl3thr0: 30 Mar, 2008 - 12:20 PM