-3

I want to run this code without Timer. I deleted Timer variables and function, but the code doesn't work, and I have just image without change. How can i run this code without timer. I need that just for one time run.

Community
  • 1
  • 1
Sani Ya
  • 9
  • 4

1 Answers1

0

Simple solution: Instead of instantiating a timer and calling timer.start(), feel free to call actionPerformed(ActionEvent e) method directly from the constructor.

The Hard Way: Your code contains a lot of mistakes. Calling actionPerformed directly from your constructor is nonsense, since there is no action event to react. Try to begin with moving the code from actionPerformed() method into createPane() method. At least.

Next issue with your code is possible drawing even before the object is constructed. You should at least make method createPane() public and call it from public static void main(String[] args) method after instantiating the ImageLabelPanel.

  • It's my [code](http://stackoverflow.com/a/3078354/230513), but I'm always interested in learning from mistakes. – trashgod Oct 10 '14 at 13:03