-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSpampedeImagePanel.java
More file actions
41 lines (33 loc) · 965 Bytes
/
Copy pathSpampedeImagePanel.java
File metadata and controls
41 lines (33 loc) · 965 Bytes
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
package com.gradescope.spampede;
import javax.swing.JPanel;
import java.awt.Dimension;
import java.awt.Image;
import java.awt.Graphics;
/**
* Implements low-level graphics work.
*
* DO NOT MODIFY.
*
* @author CS60 instructors
*/
public class SpampedeImagePanel extends JPanel {
/** The image that this panel draws */
Image myImage;
/** Constructs a new SpampedeImagePanel */
public SpampedeImagePanel(Image inputImage) {
// store the image
this.myImage = inputImage;
// calculate the dimensions of the panel
int height = inputImage.getHeight(null);
int width = inputImage.getWidth(null);
Dimension dimensions = new java.awt.Dimension(width, height);
super.setPreferredSize(dimensions);
}
/** Draws the image on the panel */
@Override
public void paint(Graphics graphicsObj) {
graphicsObj.drawImage(this.myImage, 0, 0, null);
}
/** Added to avoid a warning - not used! */
private static final long serialVersionUID = 1L;
}