Evan Evan - 6 months ago 9
Java Question

The method (method) in the type (className) is not applicable for the arguments (int)

I keep getting an error that I cannot seem to resolve. It appears on the "showSlide(elementNum);" line.

public class SlideGUI extends JPanel{


fillSlide();
showSlide();

}

private class EventListener implements ActionListener{
public void actionPerformed(ActionEvent e){
if (e.getSource() == nextButton){
elementNum++;

if(elementNum == slides.length){
elementNum = 0; //make index number 0 (the first slide)

}
}
showSlide(elementNum);
}
}


public void fillSlide(){

slides[0] = new Slide("Halong Bay.jpg",new Color(49,57,74),"Halong Bay From Lookout Point");
slides[1] = new Slide("Minion.jpg",new Color(3,28,75),"Minion Balloon");
slides[2] = new Slide("Ice Cream.jpg",new Color(13,54,72),"Chocolate Ice Cream with Yoghurt and Coffee Jelly");
}

public void showSlide(){

imageLabel.setIcon(slides[elementNum].getImage());
captionLabel.setText(slides[elementNum].getCaption());

lowerPanel.setBackground(slides[elementNum].getColour());
upperPanel.setBackground(slides[elementNum].getColour());
moveOnPanel.setBackground(slides[elementNum].getColour());
moveBackPanel.setBackground(slides[elementNum].getColour());
picturePanel.setBackground(slides[elementNum].getColour());

}
}

Answer

You call showSlide() with a parameter, but you declared it to have no parameters.