I am trying to make a JukeBox simulator, so make a string for all my songs and image I want to use, so it is no hard coded, now I am trying to make a button appear for each song. Now I want the button to contain the image representing each song, so I listed all the image in the string below and I included the button image part in the "makeButton" method, however the button image did not change.
Here is the JukeBox or the background class
This is my button (actor) class
How could I change the actor into the image in the string list?
Im not sure if the question make sense, but please comment.
public class JukeBox extends World
{
private String[] buttons = {"A", "S", "D", "F", "G"};
private String[] buttonImage = {"1.png","2.png","3.png","4.png","5.png"};
private String[] buttonSongs = {"1925.mp3", "Irony.mp3", "matryoshka.mp3", "SeasonalFeathers.mp3","Wolf&Red.mp3"};
private int [] buttonType = {1,1,1,1,1};
public JukeBox()
{
super(600, 400, 1);
makeButtons();
}
private void makeButtons()
{
for(int i = 0; i < buttons.length; i++)
{
Button button = new Button ( buttons[i], buttonSongs[i]+ "",buttonImage[i] + "", buttonType[i]);
addObject(button, i*63 + 50, 140);
addObject(button, i,160);
Stop stop = new Stop();
addObject(stop, 100, 350);
Play play = new Play();
addObject(play, 180, 350);
}
}
}public class Button extends Actor
{
private String buttonName;
private String sound;
private int typeOfButton;
private String buttonImage;
private GreenfootSound gfs;
private boolean isPlaying;
public Button(String buttons, String soundFile, String image, int buttonType)
{
buttonName = buttons;
sound = soundFile;
buttonImage = image;
typeOfButton = buttonType;
gfs = new GreenfootSound(sound);
}
