COMP2396
Loading...
Searching...
No Matches
changingoval Class Reference
Collaboration diagram for changingoval:

Classes

class  clickingListener
 
class  MyDrawPanel
 

Public Member Functions

void go ()
 
Color randomColor ()
 random returns a Color object with random values
 

Static Public Member Functions

static void main (String[] args)
 

Detailed Description

Definition at line 5 of file changingoval.java.

Member Function Documentation

◆ go()

void changingoval.go ( )
inline

Definition at line 38 of file changingoval.java.

38 {
39 JFrame frame = new JFrame();
40 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
41 frame.add(drawPanel);
42
43 JButton button = new JButton("Change color");
44 frame.add(button, BorderLayout.SOUTH);
45
46 frame.addMouseListener(new clickingListener());
47
48 frame.setSize(300, 300);
49 frame.setVisible(true);
50
51 while (true) {
52 // circle follows the mouse
53 //get the mouse position
54 Point p = frame.getMousePosition();
55 if (p != null) {
56 x = (int) p.getX();
57 y = (int) p.getY();
58 }
59 drawPanel.repaint();
60 try {
61 Thread.sleep(50);
62 } catch (Exception ex) { }
63 }
64 }

Referenced by main().

Here is the caller graph for this function:

◆ main()

static void changingoval.main ( String[] args)
inlinestatic

Definition at line 34 of file changingoval.java.

34 {
35 changingoval gui = new changingoval();
36 gui.go();
37 }

References go().

Here is the call graph for this function:

◆ randomColor()

Color changingoval.randomColor ( )
inline

random returns a Color object with random values

Definition at line 7 of file changingoval.java.

7 {
8 int red = (int) (Math.random() * 255);
9 int green = (int) (Math.random() * 255);
10 int blue = (int) (Math.random() * 255);
11 Color randomColor = new Color(red, green, blue);
12 return randomColor;
13 }
Color randomColor()
random returns a Color object with random values

References randomColor().

Referenced by randomColor().

Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this class was generated from the following file: