とにかくのIDを設定することはありますかJButton
。私はAndroidでそれに慣れています。
私は次のようなものを探しています:
newButton.setId(objectcounter);
使用できるプロパティ名があります。
newButton.setName(String.valueOf(objectCounter))
または、任意の値を保存できる clientProperties を使用できます。
newButton.putClientProperty("id", Integer.valueOf(objectCounter))
クライアント プロパティ マップから値を取得するには、次のようなものが必要です。
Object property = newButton.getClientProperty("id");
if (property instanceof Integer) {
int objectCounter = ((Integer)property);
// do stuff
}