im a complete novice programmer and am not great at it. i have to create a program that allows the user to move the dirrection a set of eyes are looking on screen.
i have buttons created and possitioned and eyes drawn. im not 100% sure what code to put behind the buttons and how to do it. help with it would be great. bellow is the code i have already done.
import javax.swing.*; import java.awt.*; import java.awt.event.*; public class RandomCircleInnerAns implements ActionListener{ JFrame frame1 = new JFrame(); public static void main(String [] args) { RandomCircleInnerAns RCA = new RandomCircleInnerAns(); RCA.go1(); } public void go1(){ JButton button = new JButton("LOOK LEFT"); JButton button1 = new JButton("LOOK RIGHT"); JButton button2 = new JButton("LOOK DOWN"); JButton button3 = new JButton("LOOK UP"); eye drawPanel = new eye(); boolean Button1; boolean Button2; boolean Button3; boolean Button4; frame1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame1.getContentPane().add(BorderLayout.CENTER,drawPanel); frame1.getContentPane().add(BorderLayout.NORTH,button3); frame1.getContentPane().add(BorderLayout.SOUTH,button2); frame1.getContentPane().add(BorderLayout.EAST,button1); frame1.getContentPane().add(BorderLayout.WEST,button); frame1.setSize(600,600); frame1.setVisible(true); } public void actionPerformed(ActionEvent event) { frame1.repaint(); } class eye extends JPanel { //inner class definition public void paintComponent(Graphics g){ { g.setColor(Color.white); g.fillRect(0, 0, 600, 600); g.setColor(Color.blue); g.drawOval(30, 60, 130, 130); g.setColor(Color.blue); g.drawOval(180,60,130,130); g.setColor(Color.black); g.fillOval(73,96,50,50); g.setColor(Color.black); g.fillOval(223,96,50,50); } } //end paintComponent }//end inner class }