java - How do I change and instance variable for an object which the user selects from a combobox? -
i'm huge noob. finished java textbook , i'm making game learning experiment. i'm stumped... here' problem:
i have 6 objects created person class.
each object has boolean variable, automatically set false.
i can select each person object combo-box , display information them, can display information use link object combo box (as in: person1.name allows me display name variable on combobox, , allows me display name elsewhere).
i want able change other instance variables within each object. know how make method change each object, i'd have make 6 methods, 1 refers each specific object.
i want change boolean instance variable object user selects combobox. thought array of objects, i've been failing set array. array right way go? or there way?
assuming jcombobox
contains reference person
object, should provide suitable getters , setters allow access value contain within object.
for example...
public class person { private string name; public string getname() { return name; } }
creates read person
, name can't changed.
but, if do...
public class person { private string name; public string getname() { return name; } public void setname(string value) { name = value; } }
this makes name property writable well, example
Comments
Post a Comment