import javax.swing.*;import java.awt.*; final public class Test1 {    JFrame frame;    DrawPanel drawPanel;    private int A = 9;    private int B = 5;    boolean Up = false;    boolean Down = true;        public static void main(String args) {        new Test1().go();    }    private DrawPanel DrawPanel;    private void go() {        frame = new JFrame(“Test ANIMATION”);        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);        DrawPanel = new DrawPanel();        frame.getContentPane().add(BorderLayout.CENTER, DrawPanel);        frame.setVisible(true);          frame.setResizable(false);        frame.setSize(200, 200);        frame.setLocation(175, 55);        moveANIME();    }    class DrawPanel extends JPanel {        public void paintComponent(Graphics g) {            g.setColor(Color.BLUE.darker());            g.fillRect(0, 0, this.getWidth(), this.getHeight());            g.setColor(Color.BLUE);            g.fillRect(3, 3, this.getWidth()-6, this.getHeight()-6);            g.setColor(Color.RED.brighter());            g.fillRect(9, 6, this.getWidth()-12, this.getHeight()-12);            g.setColor(Color.orange.brighter());            g.fillRect(A, B, 6, 6);        }    }    private void moveANIME() {        while(true){                    if(B >= 260){                Up = true;                Down = false;            }            if(B <= 7){                Up = false;                Down = true;            }            if(Up){                B--;            }            if(Down){                B++;            }            try{                Thread.sleep(12);            } catch (Exception exc){}            frame.repaint();        }    }}

x

Hi!
I'm Brenda!

Would you like to get a custom essay? How about receiving a customized one?

Check it out