I am making a seat monitoring system using java PL. I have this method in my ComputerSeats class:
public void occupySeat()
{
seatOccupied[station-1] = true;
mtr.showArrayIdVal().setText(stud.showField().getText());
seat[station-1].setBackground(Color.red);
occupiedSeatCounter++;
}
the ShowArrayIdVal contains a Jlabel[] object, the value of this label is “Vacant Station”, I used setText(stud.showField().getText()) to change “Vacant Station” to the value that I have inputted using JTextField. But then, whenever I compile it, It contains an error which states that it cannot find settext().
If
mtr.showArrayIdVal()is returning aJLabelObject your code should work fine.I assume that
mtr.showarrayidval()is returningarray of Jlable objects. so, you should be getting the object on theindexand then callsetText(...).