\r
import java.awt.*;\r
import java.awt.event.*;\r
+import java.awt.image.*;\r
\r
import javax.swing.*;\r
\r
class AnimatedPanel extends JPanel implements Runnable\r
{\r
long startTime = 0;\r
+ BufferedImage offscreen;\r
\r
public void run()\r
{\r
angle += units;\r
angle %= 360;\r
startTime = System.currentTimeMillis();\r
- repaint();\r
- }\r
- catch (Exception ex)\r
- {\r
- }\r
- }\r
\r
- angle = 0;\r
- cancel.setEnabled(false);\r
- }\r
+ if (offscreen == null || offscreen.getWidth(this) != getWidth()\r
+ || offscreen.getHeight(this) != getHeight())\r
+ {\r
+ offscreen = new BufferedImage(getWidth(), getHeight(),\r
+ BufferedImage.TYPE_INT_RGB);\r
+ }\r
\r
- synchronized public void paintComponent(Graphics g1)\r
- {\r
- Graphics2D g = (Graphics2D) g1;\r
- g.setColor(Color.white);\r
- g.fillRect(0, 0, getWidth(), getHeight());\r
+ Graphics2D g = (Graphics2D) offscreen.getGraphics();\r
+ g.setColor(Color.white);\r
+ g.fillRect(0, 0, getWidth(), getHeight());\r
\r
- if (image != null)\r
- {\r
- g.rotate(Math.toRadians(angle), 28, 28);\r
- g.drawImage(image, 10, 10, this);\r
- g.rotate(-Math.toRadians(angle), 28, 28);\r
- }\r
+ if (image != null)\r
+ {\r
+ g.rotate(Math.toRadians(angle), 28, 28);\r
+ g.drawImage(image, 10, 10, this);\r
+ g.rotate( -Math.toRadians(angle), 28, 28);\r
+ }\r
\r
- g.setFont(new Font("Arial", Font.BOLD, 12));\r
- g.setColor(Color.black);\r
+ g.setFont(new Font("Arial", Font.BOLD, 12));\r
+ g.setColor(Color.black);\r
\r
- switch (currentStatus)\r
- {\r
- case STATE_QUEUING:\r
- g.drawString(title.concat(" - queuing"), 60, 30);\r
+ switch (currentStatus)\r
+ {\r
+ case STATE_QUEUING:\r
+ g.drawString(title.concat(" - queuing"), 60, 30);\r
\r
- break;\r
+ break;\r
\r
- case STATE_RUNNING:\r
- g.drawString(title.concat(" - running"), 60, 30);\r
+ case STATE_RUNNING:\r
+ g.drawString(title.concat(" - running"), 60, 30);\r
\r
- break;\r
+ break;\r
\r
- case STATE_STOPPED_OK:\r
- g.drawString(title.concat(" - complete"), 60, 30);\r
+ case STATE_STOPPED_OK:\r
+ g.drawString(title.concat(" - complete"), 60, 30);\r
\r
- break;\r
+ break;\r
\r
- case STATE_CANCELLED_OK:\r
- g.drawString(title.concat(" - job cancelled!"), 60, 30);\r
+ case STATE_CANCELLED_OK:\r
+ g.drawString(title.concat(" - job cancelled!"), 60, 30);\r
\r
- break;\r
+ break;\r
\r
- case STATE_STOPPED_ERROR:\r
- g.drawString(title.concat(" - job error!"), 60, 30);\r
+ case STATE_STOPPED_ERROR:\r
+ g.drawString(title.concat(" - job error!"), 60, 30);\r
\r
- break;\r
+ break;\r
\r
- case STATE_STOPPED_SERVERERROR:\r
- g.drawString(title.concat(" - Server Error! (try later)"), 60,\r
- 30);\r
+ case STATE_STOPPED_SERVERERROR:\r
+ g.drawString(title.concat(" - Server Error! (try later)"),\r
+ 60,\r
+ 30);\r
\r
- break;\r
+ break;\r
+ }\r
+\r
+ repaint();\r
+ }\r
+ catch (Exception ex)\r
+ {\r
+ }\r
}\r
+\r
+ angle = 0;\r
+ cancel.setEnabled(false);\r
+ }\r
+\r
+ public void paintComponent(Graphics g1)\r
+ {\r
+ g1.drawImage(offscreen, 0,0,this);\r
}\r
}\r
}\r