mercredi 25 mars 2015

Problems with array changing elements

I am trying to change elements in an array to the word "empty" with a Jbutton and also add names through a Jtextfield if the in the selected position in the array says empty. For some reason I cant get it to work. here is the code don't know if I am missing something or I am just completely wrong



move = new JButton("Add Tennant");
window.add(move);
moveIn.addActionListener(this);

Tennant = new JTextField(FIELD_WIDTH);
nTennant.setText("Enter new name") ;
window.add(Tennant);
Tennant.addActionListener(this);

evict = new JButton("Evict");
window.add(evict);
moveIn.addActionListener(this);


different method:



if(e.getSource() == move)
{
if (occupant[selectedApartment].equals("empty"))
{
occupant[selectedApartment] = Tennant.getText();
}
}

if(e.getSource() == evict)
{
if(!occupant[selectedApartment].equals("Empty"))
{
occupant[selectedApartment] = "Empty";
}
}

Aucun commentaire:

Enregistrer un commentaire