basicly every so often an icon on a button will change
although, im quite new to java and im getting problems with using the array in the other class
public class name
{
JButton btn_M1, btn_M2, btn_M3, btn_M4, btn_M5;
JButton[] array_Buttons={btn_M1, btn_M2, btn_M3, btn_M4, btn_M5};
Icon icon_x = new ImageIcon(getClass().getResource("x.png"));
Icon icon_y = new ImageIcon(getClass().getResource("y.png"));
}
public name
{
//setting up all the buttons here
btn_M1 = new JButton("",icon_x);
btn_M1.addActionListener(this);
btn_M1.setBounds(ButtonXCo, ButtonYCo+60, ButtonSize,ButtonSize);
add(btn_M1);
}
public class TimerListener
{
public void actionPerformed(ActionEvent Action)
{
array_Buttons[5].setIcon(icon_y);//errors here
]
}
i get errors when it hits the set Icon, the icon is fine etc
just where do i need to put the array of buttons or what do i need to set it as to be able to access it, as it dosnt seem to be.
its a run time error, null pointer exception?
sorry if thats not very clear, thanks for the advice

New Topic/Question
Reply




MultiQuote







|