-
Notifications
You must be signed in to change notification settings - Fork 0
/
RandomArtist.java
46 lines (42 loc) · 1.48 KB
/
RandomArtist.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/** Main class for HA Random Artist
* can be used unchanged in most cases
*
* @author kees
* @author huub
*
* by Victor Asanache, 1567683
* and Serggio Pizzella, 1534246
* as group 188
*/
import java.awt.*;
import javax.swing.*;
public class RandomArtist {
JFrame frame;
Painting painting; // panel that provides the random painting
JButton regenerateButton;
JButton shotButton;
RandomArtist() {
// invokeLater: preferred way to create components
SwingUtilities.invokeLater( new Runnable() {
@Override
public void run() {
painting = new Painting();
frame = new JFrame("Computer Assisted Random Artist");
frame.add(painting, BorderLayout.CENTER);
regenerateButton = new JButton("Regenerate");
regenerateButton.addActionListener(painting); // painting provides reaction to buttonclick
frame.add(regenerateButton, BorderLayout.SOUTH);
shotButton = new JButton("Screenshot");
shotButton.addActionListener(painting);
frame.add(shotButton, BorderLayout.NORTH);
frame.pack();
painting.regenerate(); // can be done here since painting has a size!
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
} );
}
public static void main(String[] arg) {
new RandomArtist();
}
}