8 int red = (int) (Math.random() * 255);
9 int green = (int) (Math.random() * 255);
10 int blue = (int) (Math.random() * 255);
19 public void paintComponent(Graphics g) {
24 Graphics2D g2d = (Graphics2D) g;
27 g2d.clearRect(0,0, this.getWidth(), this.getHeight());
30 g2d.fillOval(x-70, y-70, 140, 140);
34 public static void main(String[] args) {
39 JFrame frame =
new JFrame();
40 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
43 JButton button =
new JButton(
"Change color");
44 frame.add(button, BorderLayout.SOUTH);
46 frame.addMouseListener(
new clickingListener());
48 frame.setSize(300, 300);
49 frame.setVisible(
true);
54 Point p = frame.getMousePosition();
62 }
catch (Exception ex) { }
67 public void mousePressed(MouseEvent e) {
72 public void mouseReleased(MouseEvent e) {}
73 public void mouseEntered(MouseEvent e) {}
74 public void mouseExited(MouseEvent e) {}
75 public void mouseClicked(MouseEvent e) {}