So I've been working on this project of mine and I want to refactor it.
What I have is a couple of cases that change my JButttons' icons. These cases are in a method that is in my public GUI class that extends JFrame. What I want to do is simplify the class by moving the cases onto another class. My problem is that the other class doesn't change anything. I managed to make it change an integer but no luck with the buttons.
Here is the changepic method. case 1 doesn't work, case 2 does.
public void ChangePic(int f){
switch (f){
case 1:
draftcases.CaseOne();
System.out.println(testnumber);
break;
case 2:
custom.setIcon(cards.E4En);
custom.setRolloverIcon(cards.E4Eg);
custom2.setIcon(cards.SCn);
custom2.setRolloverIcon(cards.SCg);
custom3.setIcon(cards.DCn);
custom3.setRolloverIcon(cards.DCg);
break;
Here is the DraftCases class. The testnumber does change but the buttons stay the same.
public class DraftCases {
public void CaseOne() {
GUI gui = new GUI();
Cards cards = new Cards();
gui.custom.setIcon(cards.AZn);
gui.custom.setRolloverIcon(cards.AZg);
gui.custom2.setIcon(cards.TFn);
gui.custom2.setRolloverIcon(cards.TFg);
gui.custom3.setIcon(cards.ISn);
gui.custom3.setRolloverIcon(cards.ISg);
gui.testnumber = 3;
}
}
I am a beginner and I barely know anything but this shouldn't be a problem. What am I missing?